partial upload using content-range

Last post 09-16-2008 3:17 PM by BarryR. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 09-15-2008 9:18 AM

    • ajay
    • Top 50 Contributor
    • Joined on 09-09-2008
    • Posts 8

    partial upload using content-range

    how can i partial upload a file using content-range?
    iam using 'fsockopen' to upload the file

    $data .="Accept-Ranges: bytes\r\n\r\n";
    $data .="Content-Range: bytes 0-".($_FILES['userfile']['size']-1)."\r\n\r\n";
    is not working.
  • 09-16-2008 12:44 AM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 777

    Re: partial upload using content-range

     The content range header should be in the following format:

    Content-Disposition: form-data; name="fileContent"; filename="myfile.dat"\r\n
    Content-Type: binary/octet-stream\r\n
    Content-Range: 0-4/5\r\n
    \r\n

    Let me know if that helps, there are full samples in the appendix of the documentation with difference scenerios.

    Regards,
         Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@live.com
    Gmail: barryruffner@gmail.com
  • 09-16-2008 7:50 AM In reply to

    • ajay
    • Top 50 Contributor
    • Joined on 09-09-2008
    • Posts 8

    Re: partial upload using content-range

    Thanks Barry.

    i tried the Content-Range: 0-127/560 for a file of 560 bytes

    but result in an error

    Error:Invalid upload request: the content-range must be contiguous; expected=128, actual=0.

  • 09-16-2008 3:17 PM In reply to

    • BarryR
    • Top 10 Contributor
    • Joined on 07-20-2007
    • San Diego
    • Posts 777

    Re: partial upload using content-range

     This error will occur when you have already uploaded bytes 0-127 and we are waiting for byte 128+ to come.  I'm guessing in your loop you called it a second time without incrementing the position.  The second send in this case would be 128-256/560, then just repeat until you are at the end of the file.  When you get a bit closer be sure to use chunks of about 4 Mb each or you could see significant performance impact.

    Regards,
         Barry R.

    IM Support (Feel free to add me)

    MSN: barryruffner@live.com
    Gmail: barryruffner@gmail.com
Page 1 of 1 (4 items)