|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
|
|
#1
|
|||
|
|||
|
Hey all, I have been trying for a couple days now to get a purely ASP based file upload script to work. I have tried 3'rd party .dll solutions, and nothing seems to work. (I tried to use aspsmart upload and could not get it to run properly, if you have gotten it to run maybe you could PM me? )
Anyhow for the time being I am using an ASP.net solution which uses the C# language I belive. Now the script works fine, but the only problem is that since I do not know much about asp.net and the included sub-languages I am at a loss as to attempt to record the filenames and store them in a Dbase. The file is uploaded, then it responds by telling you "test.txt" has been uploaded successfully. But I cannot seem to find any way in which to isolate the part of the code that displays the filename(s), which means I cannot store them and submit them to a Dbase. So, after all that horrible explaining here is the code which works flawlessly (at least on my system): <%@ Page Language="C#" %> <script runat="server"> void Button1_Click(object Source, EventArgs e) { txtMsg.InnerHtml = saveFiles(); } string saveFiles() { string strMessage = ""; string strFileName; HttpPostedFile objFile; for (int i=0; i<Request.Files.Count; i++) { objFile = Request.Files[i]; if (objFile.FileName != "") { strFileName = objFile.FileName; strFileName = strFileName.Substring(strFileName.LastIndexOf("\\")+1); try { objFile.SaveAs("c:\\upload\\"+strFileName); strMessage+= "Uploaded: c:\\upload\\"+strFileName+"<br>"; } catch (Exception err) { strMessage+= "Failed uploading "+strFileName+": "+err.ToString()+"<br>"; } } } return strMessage; } </script> <html> <head> <title>Multiple File Upload with ASP.NET</title> </head> <body> <b>Multiple File Upload Sample</b> <form id="frmUp" enctype="multipart/form-data" runat="server"> Select file for upload: <input id="txtFile" type="file" runat="server"> <br> Select file for upload: <input id="txtFile2" type="file" runat="server"> <br> Select file for upload: <input id="txtFile3" type="file" runat="server"> <br> <span id=txtMsg runat="server" /> <br> <input type=button id="Button1" value="Upload" OnServerClick="Button1_Click" runat="server"> </form> </body> </html> Can anyone either help me out with finding out the variables that store the filename(s) or tell me where I can find another ASP upload solution in which I can store the filenames without hassle cause I cannot seem to get 3'rd party solutions to work.Thanks for any help/suggestions you can give me, Chris [EDIT] Oh look I'm an idiot, the variable for the file name is strFileName but I do not know how to call up all of the three files that could have been uploaded? [There are 3 possible files you can upload, how would I go about calling all 3 of those filenames?] Last edited by colonel_klink : July 4th, 2003 at 04:03 PM. |
|
#2
|
|||
|
|||
|
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Having trouble finding variable for filename in ASP.net |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|