ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 4th, 2003, 04:00 PM
colonel_klink colonel_klink is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 12 colonel_klink User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Having trouble finding variable for filename in ASP.net

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.

Reply With Quote
  #2  
Old July 4th, 2003, 04:13 PM
mic dynamic mic dynamic is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Switzerland
Posts: 28 mic dynamic User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to mic dynamic
search at www.hotscripts.com
you'll find any good scripts.

goodluck
mic

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Having trouble finding variable for filename in ASP.net


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway