LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 04-23-2008, 07:16 PM   #1
lukebeales
Member
 
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.

Code:

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

filedatagoesinhere
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, 09:28 PM   #2
irish_rover
Member
 
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, 09:54 PM   #3
lukebeales
Member
 
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.

Thanks!
 
  


Reply

Tags
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 01:53 PM
PHP and File Uploading Tomasfuego Linux - Software 6 08-12-2004 10:20 AM
Error uploading file with PHP jacksmash Programming 8 11-22-2003 12:11 PM
Trouble recognising 'post' data in a php file davee Programming 4 10-20-2003 01:29 PM
uploading with apache and php chens_83 Linux - General 6 02-16-2003 06:09 AM


All times are GMT -5. The time now is 07:29 AM.

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