Click to See Complete Forum and Search --> : Uploading Pictures to server with ASP - PLEASE HELP!
Decayed
April 2nd, 2001, 10:30 AM
Hi, please help me, i need to figure out how to upload a picture file (jpg, gif) or whatever (wav, etc) to the server from an asp page..
1. Is it possible to bring out a select file dialog and then the user selects the file and an upload starts (JUST LIKE UPLOADING MP3S ON MP3.COM)..
2. And how do i figure out when such file transfer is finished so i can redirect the page or something.
I need this badly, so if you have any idea or a piece of code please reply!
---------------------------------
The Decayed - the_decayed@hotmail.com
Johnny101
April 2nd, 2001, 02:30 PM
there was an article on www.asptoday.com that gave great examples of how to upload files using pure VBScript. search for "upload vbscript" and you should see it. there are also a number of third party controls that handle this sort of thing. check out www.aspupload.com for example.
uploading the file is a syncronous operation, meaning that your script will wait until the file has been fully uploaded into memory before executing, so no special "timing" code required.
hope this helps,
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
Decayed
April 2nd, 2001, 02:48 PM
well, if i would have 50$ i'm sure i would check it out, but now i guess i'll just stay clueless for a while.. Unless you can give me a free tip.
---------------------------------
The Decayed - the_decayed@hotmail.com
Johnny101
April 2nd, 2001, 05:12 PM
there are two properties of the Request object that are key to doing it yourself.
be sure to set the enctype property of the form tag correctly - it should be "multipart/form-data".
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="upload.asp">
<INPUT TYPE="file" NAME="blob"><BR>
<INPUT TYPE="submit" NAME="Enter">
</FORM>
if you plan on having only one field in the upload form, then uploading becomes alittle easier. the two properties to use are BinaryRead and TotalBytes. here's a sample:
dim byteCount
dim btyeStream
byteCount = Request.TotalBytes
byteStream = Request.BinaryRead(byteCount)
now that you have the bytestream, save it to a file. you can later rename it to whatever you want. there are some other quirks and tweaks, but then i'd be regurgicating the entire article and i think that infringes on Copyright laws. :(
good luck,
john
John Pirkey
MCSD
http://www.ShallowWaterSystems.com
http://www.stlvbug.org
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.