CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2000
    Posts
    18

    Uploading Pictures to server with ASP - PLEASE HELP!

    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 - [email protected]

  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Uploading Pictures to server with ASP - PLEASE HELP!

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

  3. #3
    Join Date
    Feb 2000
    Posts
    18

    Re: Uploading Pictures to server with ASP - PLEASE HELP!

    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 - [email protected]

  4. #4
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Uploading Pictures to server with ASP - PLEASE HELP!

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured