Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I working on one page which is in Classic ASP.
I want include a file upload option in it and want to store the uploaded file in a folder.
I am planning to use jQuery for the same.
Kindly suggest is it good option or any better option is there.
Posted

1 solution

/*Store Folder path */
hdfUploadPath.Value = "Folder Path where you want to store your file"+ "\\";

/*Creating Directory*/
if (!Directory.Exists(hdfUploadPath.Value))
{
Directory.CreateDirectory(hdfUploadPath.Value);
}

/*To get user uploaded file name*/
UploadedFile filename = UploadID.UploadedFiles[0];//"UploadID" is FileUpload ID
strGetFileName = filename.GetName();

/*Path to save user uploaded file*/
string strFileName = hdfUploadPath.Value + strGetFileName;

/*existence of file if not exists then saving else giving message to user*/
if (!File.Exists(strFileName))
{
filename.SaveAs(strFileName, true);
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Error", "alert('File already exist or rename file then upload');", true);
return;
}
 
Share this answer
 
v2
Comments
Arunprasath Natarajan 8-Oct-12 1:35am    
Seems to be C#, Is it Classic ASP.
If no, since the existing pages are in Classic ASP, I want to do it in same.
sanjaygajera123 17-Dec-12 12:49pm    
Dear expert,
i want to upload file using ASP programming .
i have tried below code for file save on the server but it gives me an error,

<%
Set Upload = Server.CreateObject("Persits.Upload")
Upload.SetMaxSize 1048576 ' Truncate files above 1MB
Upload.Save Server.MapPath("/upload/")

%>

above code throws an error of Object creation.

please give the solution as soon as possible.

regards,
sanjay gajera
+91 89050 74894

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900