Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-23-2008, 06:16 PM   #1
Registered: Oct 2003
Location: Australia
Distribution: Slackware/LFS/Ubuntu
Posts: 89

Rep: Reputation: 15
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.
Old 04-23-2008, 08:28 PM   #2
Registered: Sep 2002
Location: IN, USA
Distribution: Debian, Endian FW
Posts: 368

Rep: Reputation: 30
Have you checked the file size limit that is set in the php config?
Old 04-23-2008, 08:54 PM   #3
Registered: Oct 2003
Location: Australia
Distribution: Slackware/LFS/Ubuntu
Posts: 89

Original Poster
Rep: Reputation: 15
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.



file, php, post, upload

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
file upload with php+libcurl via POST Cupacabra Linux - Software 0 01-12-2005 12:53 PM
PHP and File Uploading Tomasfuego Linux - Software 6 08-12-2004 09:20 AM
Error uploading file with PHP jacksmash Programming 8 11-22-2003 11:11 AM
Trouble recognising 'post' data in a php file davee Programming 4 10-20-2003 12:29 PM
uploading with apache and php chens_83 Linux - General 6 02-16-2003 05:09 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:32 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration