-   Programming (
-   -   uploading file with POST from PHP issue (

lukebeales 04-23-2008 07:16 PM

uploading file with POST from PHP issue
Hi All,
I'm trying to create my own POST multipart session from PHP which is all working except for transferring certain files. Eg. PHP is connecting to a website and acting like it is a form that has just been submitted with a file. The filesize doesn't seem to matter but more the mime type.



content-disposition: form-data; name="file"; filename="filename.tar.bz2"
Content-Type: mime-type-in-here
Content-Transfer-Encoding: application/octet-stream


That is what I am using so far and php manages to see the file but comes back and says it never finished uploading. Yet if I use the same filename and just change it to simple text file it all goes through smoothly. tar.gz doesn't work, neither does .tar. I'm thinking it's the encoding I'm using or the way I am reading the file in (using file_get_contents). Is there a better way to do this? Thanks for any suggestions in advance.

irish_rover 04-23-2008 09:28 PM

Have you checked the file size limit that is set in the php config?

lukebeales 04-23-2008 09:54 PM

Yep sorry just managed to solve it then.

Just incase anyone else is having the same problem, the issue was every boundary needs to be on a new line it looks like. I was reading the file data out and then placing a boundary string after it without going on a new line, so it must have been treating it as part of the file and therefore not seeing any ending boundary. Simple fix - place a newline after reading the file.


All times are GMT -5. The time now is 03:20 PM.