Given this one a few hours research and thought but I'm not getting anywhere.
I have managed to get an image file to upload through AJAX using a FormData object. When the file reaches the php code I am able to access its info such as 'name' and 'type' by using:
$_FILES['newFile']['name'];
$_FILES['newFile']['type'];
And so on, which means that the file must be uploading as intended, I just can't seem to save it to a file from there.
I have tried:
$file = file_get_contents($_FILES["newFile"]['tmp_name']);
imagejpeg($file, '/img/uploads/' . $_FILES["newFile"]['name']);
But then imagejpeg gives me the error "Expects paramater1 to be resource, string given." So I tried:
$file = imagecreatefromstring(file_get_contents($_FILES["newFile"]['tmp_name']));
imagejpeg($file, '/img/uploads/' . $_FILES["newFile"]['name']);
I now receive the error: /"imagejpeg('/img/uploads/image.jpg'): Failed to open stream. No such file or directory."
Can someone explain how I get the image from the array to a file on disk?