cURL Upload File to PHP cURL Upload File to PHP curl curl

cURL Upload File to PHP


Your $_FILES["file"]["type"] check is failing because cURL doesn't make any guesses to the type and won't send that automatically in the POST request.

This is easily spoofed so it's not a great check anyway.

But to make your example work, try specifying the content type with the file parameter:

curl -F file=@test.mp4;type=video/mp4 http://localhost:1337/upload_file.php


Further to what drew010 wrote (I'd write a comment but don't have the reputation yet), trusting those values passed in may actually be a security risk and has been used to hack sites in the past so be careful.