Background uploads

Discussion in 'PHP' started by rps111, Aug 24, 2007.

  1. #1
    Dear all
    I want a small piece of help. I have designed a PHP form to upload a file and some other text fields. How can I initiate background uploads even before the form is uploaded
     
    rps111, Aug 24, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Without the user knowing it? Unless you do something tricky with Javascript and iFrames, you can't. But explain a bit better what exactly you're trying to do.
     
    nico_swd, Aug 25, 2007 IP
  3. rps111

    rps111 Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I want that as the user is filling the forms, the data be transfered to the database and the file selected for upload should also start uploading before the user clicks the SUBMIT button.

    Yes, the upload should not be in the knowledge of the user. The only reason for this is that the users can submit more number of files in a limited amount of time.
     
    rps111, Aug 28, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Make a separate form for each file and put each in an iframe, then use the onchange attribute to make the form submit when the user selects a file.
     
    nico_swd, Aug 29, 2007 IP
  5. kisamesama

    kisamesama Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    use AJAX and a php script to upload you file
     
    kisamesama, Aug 29, 2007 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    AJAX doesn't support file uploading.
     
    nico_swd, Aug 29, 2007 IP
  7. ssanders82

    ssanders82 Peon

    Messages:
    77
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    How does GMail do it? When I add an attachment in Gmail, if I sit there without submitting the form, it uploads the file automatically. I assumed it was an AJAX call to force form.submit(), but nico you're saying AJAX doesn't support file uploading?
     
    ssanders82, Aug 29, 2007 IP
  8. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #8
    It's a tricky method with iframes probably. There is no way to upload a file with AJAX. Search a bit around if you want, you'll see they're all using tricky methods, but none uses AJAX alone.
     
    nico_swd, Aug 29, 2007 IP
  9. sabmalik

    sabmalik Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    i have studied Gmails code with alot of effort cause of obfuscation , turns out they ARE actually using iframes. And yes AJAX doesnt support file uploads. (thanks God)
     
    sabmalik, Aug 29, 2007 IP
  10. kisamesama

    kisamesama Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    oh srry my error :(... just started learning AJAX... yeah iframe is very useful!! was using iframe tricks when i wasn't aware there was AJAX
     
    kisamesama, Aug 30, 2007 IP
  11. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #11
    No worries, we're all here to learn. :)
     
    nico_swd, Aug 30, 2007 IP
  12. rps111

    rps111 Peon

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Can someone please help me with a sample code? I am new to web development and dont know much about this kind of stuff.

    Thanks in advance.
     
    rps111, Aug 31, 2007 IP