Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Upload not working

Status
Not open for further replies.

kpierick

ISP
Jul 31, 2002
22
US
I have the following code an html form that posts to an asp page see "general" code below:

Add-Item-Form.html
<form method=&quot;post&quot; action=&quot;Add-Item.asp&quot; enctype=&quot;multipart/form-data&quot;>
<tr>
<td align=&quot;Right&quot; width=&quot;380&quot;><P class=&quot;Yellow18Bold&quot;>ITEM PHOTO(2)&nbsp;&nbsp;</td>
<td align=&quot;Left&quot; width=&quot;380&quot;><input type=&quot;file&quot; name=&quot;txtItemPhoto2&quot; size=&quot;50&quot; tabindex=&quot;6&quot;></td>
</tr>
<tr>
<td align=&quot;center&quot; colspan=&quot;2&quot;><input type=&quot;submit&quot; name=&quot;SubmitButton&quot; value=&quot;Add&quot; tabindex=&quot;7&quot;>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=&quot;reset&quot; value=&quot;Clear&quot; tabindex=&quot;8&quot;></td>
</tr>
</form>

Add-Item.asp
(File Uploader Ojbect - called here)
<%For Each File In Uploader.Files.Items%>
<!---Save the file--->
<%Dim ImageFolder%>
<%ImageFolder = &quot;UploadedImages\&quot;%>
<%File.SaveToDisk (ImageFolder)%>
<%strIPName = &quot;UploadedImages\&quot; & File.FileName%>
<!--- will execute stored procedure: add_tblItemPhoto to insert header info into table: tblItemPhoto --->
<!-- #include file=&quot;_add-tblItemPhoto.asp&quot; --> <%Next%>

The html code works fine...
The &quot;file uploader object&quot; returns the correct information - (I.E. FileName)

The File.SaveToDisk is not working!!!!!
I get no error message, it's almost like it just doesn't run the command.

It does go to the next line and does the include - which runs a stored procedure to insert the FileName into a table that I later retrieve to display the file that was uploaded.

Why is the File.SaveToDisk not working???? The folder I'm save the file to is at the following location under the inetpub/
The code sits at inetpub/
Am I just using an incorrect path somewhere???? or would there be some sort of permission I'm missing???
 
Why don't you try to set the ImageFolder = &quot;fullpath&quot;
(ei. c:/mydocuments....)and see if the file is saved there?
 
The problem with that is that this is a web application. So if someone on the &quot;web&quot; uploades a file - won't it upload the the files to the &quot;c:/&quot; drive of the machine that the user is on - rather than on the web server itself. I need to be able to view whatever files/images are uploaded on the webserver on a different page from where it is uploaded.
 
I have exactly the same problem kpierick is with now.I try using a fullpath and it works, but if u host ur page in a webserver, most of the time u wouldn't know the fullpath . Hope any expert can help us
 
kpierick -> It won't , takes the server path.
So you need to make sure the path is right.
Get it with the servervariables.
To see all the servervariables paste this in an ASP.
<body>
<h1>Toon alle server variabelen:</h1>
<blockquote>
<table border=&quot;0&quot; cellpadding=&quot;3&quot;>
<tr valign=&quot;top&quot;>
<td align=&quot;right&quot;><b>server variabele</b></td>
<td><b>Waarde</b></td>
</tr>
<% For each key in Request.ServerVariables %>
<tr valign=&quot;top&quot;>
<td align=&quot;right&quot;><strong><%=key%></strong></td>
<td> <b><font color=&quot;#CC0000&quot;><%= Request.ServerVariables(key) %></font></b>
<% If Request.ServerVariables(key) = &quot;&quot; Then %>
<font color=&quot;#3300FF&quot;>Geen informatie beschikbaar</font>
<%End If %>
</td>
</tr>
<% Next %>
</table>
</blockquote>
<hr />
</body>

The following 2 will show you path data

<%= Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)%>
<%= Request.ServerVariables(&quot;PATH_INFO&quot;)%>

have fun with it :)
 
thx man i think that should be what i need :D
but im not very sure which server variables to choose
i try using
Request.ServerVariables(&quot;PATH_TRANSLATED&quot;)

and guess this is the right one cause its the only i got error. i read articles said that uploading to the webserver require the admin to activate ur write permission or something like that. i got &quot;page cannot be view&quot; when using that path. Is it cause by the web permission?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top