Reputation: 1081
So I have a "Skeleton" written for my projects' RESTful API. I've been trying to POST data to the store() function through cURL. And so I used
if(Input::hasfile('file'))
to check if the image/data was posting and it returned false. How would I actually detect the image/data if I were to post it via a cURL request similar to this
curl.exe --user "admin:password" --header "Content-Type: multipart/form-data" --data-binary "@vok.png" --output "out.txt" --dump-header "header.txt" http://bitdrops.co/bitdrops/public/index.php/api/v1/drop/
Ignore the header and response output.
This is my current code for the store() function.
public function store()
{
$file = Input::file('file');
$destinationPath = public_path() . '/uploads';
$filename = $file->getClientOriginalName();
//$extension =$file->getClientOriginalExtension();
$upload_success = Input::file('file')->move($destinationPath, $filename);
if( $upload_success ) {
return Response::json('success', 200);
} else {
return Response::json('error', 400);
}
}
Upvotes: 1
Views: 1628
Reputation: 2592
The issue appears that in your cURL statement
curl.exe --user "admin:password" --header "Content-Type: multipart/form-data" --data-binary "@vok.png" --output "out.txt" --dump-header "header.txt" http://bitdrops.co/bitdrops/public/index.php/api/v1/drop/
You are not passing the file as "file". As you commented earlier on the solution is:
curl.exe -i --user user:pass -F [email protected] --output "out.html" http://bitdrops.co/bitdrops/public/index.php/api/v1/drop
Upvotes: 1