How can I upload a file and put it into a ASP variable?

Results 1 to 2 of 2

Thread: How can I upload a file and put it into a ASP variable?

  1. #1
    Paco Marin Guest

    Default How can I upload a file and put it into a ASP variable?

    I&#039m doing a page where I need to upload images into a database.<BR>For that, the first thing I need it&#039s to upload the image into a variable. How could I do this?<BR>Thanks.

  2. #2
    Join Date
    Dec 1969
    Posts
    308

    Default RE: How can I upload a file and put it into a ASP variable?

    I don&#039t know what you are using to actually recieve the file upload on the server side, so i&#039m going to assume it is a component like Software Artisans FileUp. Here is some code that shows how to handle a file submission:<BR><BR>&#060;% Set file = Server.CreateObject("SoftArtisans.FileUp") &#037;&#062;<BR>&#060;% file.Path = "d:yourpath\" &#037;&#062;<BR>&#060;% &#039response.write file.path &#037;&#062;<BR>&#060;% &#039This next part checks to see if anything was uploaded. I have two things to check: the actual file and a description &#037;&#062;<BR>&#060;% if file.form("notes") = "" or file.form("file1") = "" then &#037;&#062;<BR>&#060;div align=center>&#060;font face="Verdana" color="Red" size=2>An error occured.<BR>&#060;ul>&#060;li>Please ensure you have selected a file to upload. &#060;li>Please ensure that you have included a description of the file you are uploading.&#060;/font>&#060;/ul><BR><BR>&#060;a href=addfiles.asp>Go Back&#060;/a>&#060;/div><BR><BR>&#060;% else &#037;&#062;<BR><BR>&#060;font face="Verdana">Uploading file...&#060;/font><BR>&#060;% notes = file.form("notes") &#037;&#062;<BR>&#060;% NewFileName = Mid(file.UserFilename, InstrRev(file.UserFilename, "\") + 1) &#039extracts the file name.&#037;&#062;<BR>&#060;% file.SaveAs NewfileName &#037;&#062;<BR>&#060;% end if &#037;&#062;<BR><BR>I&#039m not sure if that was exactly what you were looking for. I built a pretty lage FTP application using ASP so i have a little experience with this. If you have any questions, email me at ussweb@yahoo.com<BR><BR>-brad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •