Click to See Complete Forum and Search --> : ASP Upload


jkruer01
08-13-2003, 05:05 PM
Hello,

I am trying to create a form where someone can upload a file to the webserver. Once I choose the file and click submit, I recieve the "Page Cannot Be Displayed Error". Can you please look at my code and tell me what is wrong? I know that the page is there because the target is the same page as the form page. Any suggestions would be appreciated.

Thanks,


<%
Option Explicit

Dim upl, NewFileName

Set upl = Server.CreateObject("ASPSimpleUpload.Upload")

If Len(upl.Form("File1")) > 0 Then
NewFileName = "http://www.myurl.com/folder/" & upl.ExtractFileName(upl.Form("File1"))
If upl.SaveToWeb("File1", NewFileName) Then
Response.Write("File successfully written to disk.")
Else
Response.Write("There was an error saving the file to disk.")
End If
End If
%>


<form action="challenger.asp" method="post" enctype="multipart/form-data">
<table align="center">
<tr>
<td>Select File ("challenger.pdf")</td>
<td><input type="File" name="File1"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="Submit" value="Upload..."></td>
</tr>
</table>
</form>
</body>
</html>

rdoekes
08-14-2003, 06:05 AM
1. have you set the write permissions to Everyone in your folder?
2. You use a full path to the web server. Since SaveToWeb calls Server.MapPath, you are bound to the rules for Server.MapPath. And this Server method does not allow a full path, only relative paths.
I suspect NewFileName = "/folder/" & upl.ExtractFileName(upl.Form("File1")) will work for you.

-Rogier Doekes

jkruer01
08-14-2003, 06:34 AM
So what if the place where my upload page is, is in a different folder? (i.e. my upload page is in:
http://www.myurl.com/OTHERfolder/
and I want my file to go into
http://www.myurl.com/folder/

Can I use this:
NewFileName = "../folder/" & upl.ExtractFileName(upl.Form("File1"))

By the way, thanks for the info about the "Friendly error messages." Also, yes the folder has write permissions to everyone.

Thanks,

rdoekes
08-14-2003, 06:36 AM
yes