ayha1999
asked on
File Upload
Could anyone pls. provide me a working sample of multiple file upload inside materpage? I am using asp.net 4 and C#.
thanks
ayha
thanks
ayha
ASKER
I converted the code to c# then I got an error message
CS0118: 'uploadedFiles' is a 'variable' but is used like a 'method'
Source Error:
Line 21: HttpPostedFile userPostedFile = uploadedFiles(i);
CS0118: 'uploadedFiles' is a 'variable' but is used like a 'method'
Source Error:
Line 21: HttpPostedFile userPostedFile = uploadedFiles(i);
string filepath = "C:\\Uploads";
HttpFileCollection uploadedFiles = Request.Files;
int i = 0;
while (!(i == uploadedFiles.Count))
{
HttpPostedFile userPostedFile = uploadedFiles(i);
try
{
if ((userPostedFile.ContentLength > 0))
{
Label1.Text += "<u>File #" + (i + 1) + "</u><br>";
Label1.Text += "File Content Type: " + userPostedFile.ContentType + "<br>";
Label1.Text += "File Size: " + userPostedFile.ContentLength + "kb<br>";
Label1.Text += "File Name: " + userPostedFile.FileName + "<br>";
userPostedFile.SaveAs(filepath + "\\" + System.IO.Path.GetFileName(userPostedFile.FileName));
Label1.Text += "Location where saved: " + filepath + "\\" + System.IO.Path.GetFileName(userPostedFile.FileName) + "<p>";
}
}
catch (Exception ex)
{
Label1.Text += "Error:<br>" + ex.Message;
}
i += 1;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
there was some error in the c# code. now it works. where can I filter the type of the uploading file? can u tell how to change the file while uploading?
thanks
thanks
ASKER
is it for single file or multiple upload?
ayha
ayha
ASKER
thanks
try this sample code !!
Open in new window