1

Sending the wrong mime-type. the file type "video/mp4" but "application / octet-stream" as the sending. I want to send "video/mp4". Curl option($file = real path)

$post = array('videoupload'=>'1','input_1'=>"@$file");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_INFILESIZE,(string)filesize($file));
curl_setopt($ch, CURLOPT_INFILE,fopen($file,'r'));

Http debugger Out

------------------------------94a50e65d9fe Content-Disposition: form-data; name="videoupload"

1 ------------------------------94a50e65d9fe Content-Disposition: form-data; name="input_1"; filename="1.mp4" Content-Type: application/octet-stream

I've tried it

$post = array('videoupload'=>'1','input_1'=>"@$file;type=video/mp4");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_INFILESIZE,(string)filesize($file));
curl_setopt($ch, CURLOPT_INFILE,fopen($file,'r'));

curl_error out:

failed creating formpost data

6
  • Don't you want CURLOPT_HTTPHEADER? See: stackoverflow.com/questions/356705/… Commented Mar 25, 2013 at 19:25
  • header is correct(Content-Type: multipart/form-data"). remote server checking file mime-type($_FILES['input_1']["type"]). Commented Mar 25, 2013 at 19:33
  • You might want to update the question to be more clear. Anyway, you never want to trust $_FILES[..]['type'] - Try and use something like finfo if you need to do this. Commented Mar 25, 2013 at 19:38
  • Http Debugger(Google Chrome):Content-type:multipart/form-data; tny.cz/d4a8fba5 Http Debugger(Curl): Content-type:multipart/form-data; tny.cz/acd09926 Commented Mar 25, 2013 at 20:33
  • 1
    Is this post ever going to help anyone else? Maybe OP can update the question and better explain the solution? I still don't even know I understand the question being asked. Commented Mar 26, 2013 at 15:40

1 Answer 1

0

try adding CURLOPT_HTTPHEADER in curl_setopt like that

curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: video/mp4'));
Sign up to request clarification or add additional context in comments.

4 Comments

header is correct(Content-Type: multipart/form-data"). Because not only the video. Data is available.
Ok, but php.net/manual/en/curl.installation.php says, In order to enable this module on a Windows environment, libeay32.dll and ssleay32.dll must be present in your PATH. You don't need libcurl.dll from the cURL site.. Is really we need curl on windows to run php-curl ?
But yes it can be possible if header content-type have different behavior on windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.