Library tutorials & articles
Using the SAFileup component
- Introduction
- Using FileUp
- The code
The code
Next you see is the <input> tag having a type value as "FILE" so when you put this is a regular HTML page the browser understands that a file has to be uploaded and hence you see a button for "Browse..."
<input TYPE="FILE" NAME="fileUpload">
The submit code (below) on the other hand as below POST's the data to the server side and the file is uploaded to the directory specified.
<input type="submit" name="submiter" value="Submit">
Please make sure you have PWS/IIS running on your machine which supports server side code like ASP in this case.
Make sure you put all the files in the same virtual directory!
Recommended Spec
Windows 2000 (Win98 with PWS is also fine)
RAM: 128MB
IIS 4.0 and up (IIS 5.0 recommended)
The working code
<html>
<%
if Request.QueryString("uploader") = "true" then
Set upl = Server.CreateObject("SoftArtisans.FileUp") ' Creating upl object!
basePath = Server.MapPath(".") ' mapping the default path where files will be stored on the hard disk!
upl.Path = basePath & "\uploads"
if not upl.IsEmpty Then 'we check if the object is empty or has a null value!
'on error resume next
upl.Save 'Saving the uploaded file
strFile = upl.UserFilename 'Storing name of the file in a temporary variable!
strFileTemp = strFile
aryFileName = Split(strFile,"\")
lastVal = UBound(aryFileName) 'Checking the Ubound after spliting the file name!
strFile = aryFileName(lastVal)
strFileTemp = strFile 'actual file name with its type stored in a variable!
end If
end if
%>
<head>
<link rel="stylesheet" href="styler.css">
<script>
//This function checks to see if the user has selected some file using browse option
//If there is no proper path then it alerts user to please select a file.
function checkForm()
{
if (document.form1.fileUpload.value.length>2)
{
return (true);
}
else
{
alert("Please select an image file to upload.");
return (false);
}
}
</script>
<title>Image Upload</title>
</head>
<body bgcolor="#edf3f8">
<form ENCTYPE="MULTIPART/FORM-DATA" ACTION="index.asp?uploader=true" METHOD="POST" id="form1" name="form1" onsubmit="javascript:return checkForm();">
<table width="100%">
<tr>
<td class="contentBold" height="20">
Uploading files using SAFileup utility!<br>
</td>
</tr>
<tr>
<td class="content" height="20"></td>
</tr>
</table>
<%if Request.QueryString("uploader") = "true" then%>
<table width="100%">
<tr>
<td class="content2" height="20">
Your file <b><%=strFileTemp%></b> was successfully uploaded!<br><br>
<a class="upload" href=#" onclick="history.back(-1);">Click to upload more files.<a>
</td>
</tr>
</table>
<%else%>
<table width="100%">
<tr>
<td class="contentBold" height="20">
Select an image file you would like to upload.<br>
<input TYPE="FILE" NAME="fileUpload">
</td>
</tr>
<tr>
<td class="content"><img src="pixel.gif" height="10" width="1"></td>
</tr>
</table>
<div align="left"><input type="submit" name="submiter" value="Submit"></div>
<%end if%>
</form>
</body>
</html>
Related articles
Related discussion
-
Header and Footer in Web page print
by fhajaj (4 replies)
-
help me to get simple requirement
by Slicksim (1 replies)
-
Gridview -> Template Field -> Button
by antti.simonen (1 replies)
-
Classic ASP : Page expires
by chezhian_in05 (0 replies)
-
ASP VS PHP
by paulfp (9 replies)
Related podcasts
-
ASP.NET Caching and Performance
Steve Smith, owner of ASP Alliance and Lake Quincy Media joins us today to teach us about some hidden gems in ASP.NET caching and performance. Steve’s expertise in this area comes from first-hand experience as Lake Quincy’s ad system serves over 60 requests per second and handles over 150 million...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Microsoft Dynamics CRM Technical Consultant
in Netherlands (€50K-€90K per annum) -
Technical Support Engineer EMEA
in Reading (£50K-£50K per annum) -
Solutions Engineer
in Reading (£50K-£60K per annum)
Thanks for the help!!!
I'm going to take a look to the sites you recommended.
Regards,
Pedro Röseler
Hello
Javascript is a client side language so u cannot use javascript but server side java could be used but i don't know how
there are heaps of other upload components out there and i there are also some pure asp upload pages out there aswell at planet-source-code.com and at http://www.4guysfromrolla.com/
Can anyone help me finding code to replace the SA fileup component with javascrip code so that i don't have to use that component?
((
The server where i have a site that i build doesn't have that componet so i'm in big trouble!!!
Thanks!
pedro
pedro_roseler@mail.pt
This thread is for discussions of Using the SAFileup component.