Reputation: 5859
Do you know how to save a file that is being uploaded using the file_get_contents('php://input')
Below is what I have
public function upload_image()
{
$str = file_get_contents('php://input');
$filename = md5(time()) . '.jpg'; // I don't want to use this line
$path = public_path() . '/uploads/' . $filename; // I want to use original file name here
file_put_contents($path, $str);
echo $filename;
}
Upvotes: 1
Views: 789
Reputation: 139
You need to pass the file name with the form parameters since the file name is not sent by the request
You can check these answers
How to get filename in php in put request
Upvotes: 1