Shooyoo :Mobile Games and Entertainment Information Portal

Search: PositionHOME > SMS > Problem with file upload
0 Vote

Problem with file upload

  Post at : 2008-08-25 17:20:53   View:7  Zoom:【B M S】  

Hello,
I download the multiple file upload script from here
http://www.asp.net/learn/videos/video-252.aspx
And I get this error when i try to run it
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0103: The name 'file' does not exist in the current contextSource Error:
Line 29: for (int i = 0; i < uploads.Count; i++)
Line 30: {
Line 31: HttpPostedFile upload = file;
Line 32:
Line 33: if (upload.ContentLength == 0)Source File: c:\inetpub\wwwroot\cells\welcome\sms_upload.aspx.cs Line: 31
using System;using System.IO;using System.Configuration;using System.Data;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;
public partial class welcome_sms_upload : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { String UpPath; UpPath = "C:\\upload\\";
if (!Directory.Exists(UpPath)) { Directory.CreateDirectory("C:\\upload\\"); } } protected void btnSubmit_Click(object sender, EventArgs e) { HttpFileCollection uploads = HttpContext.Current.Request.Files; for (int i = 0; i < uploads.Count; i++) { HttpPostedFile upload = file;
if (upload.ContentLength == 0) continue;
string c = System.IO.Path.GetFileName(upload.FileName); // We don't need the path, just the name.
try { upload.SaveAs("C:\\upload\\" + c); Span1.InnerHtml = "Upload(s) Successful."; } catch (Exception Exp) { Span1.InnerHtml = "Upload(s) FAILED."; } } } protected void Button1_Click(object sender, EventArgs e) {
}
}


Tags sms
Make a comment
Name:Website:

Links

RSS - SiteMap - Top