i'm trying to send an image through a upload form to a php script but the file doesn't show in my temporary folder.
I've tried searching for the error and came upon this answer. After checking each of these steps several times I still find myself with no uploaded file...
The form :
<form id="addImageForm" action="functions/add_image.php" method="POST" enctype="multipart/form-data">
<label for="articleImage">Select a file:</label>
<input type="file" name="articleImage" id="articleImage">
<input type="submit" class="btn btn-success" value="Submit">
</form>
The add_image.php script :
<?php
/* Checking request parameters */
if(!isset($_FILES['articleImage']) || empty($_FILES['articleImage'])) {
echo "Error : the file is missing";
die();
}
/* Checking upload errors */
if($_FILES['articleImage']['error'] != UPLOAD_ERR_OK) {
echo "Error : ".$_FILES['articleImage']['error'];
die();
}
/* Checking file size */
if($_FILES['articleImage']['size'] == 0) {
echo "Error : the file is empty";
die();
}
/* Checking file has been uploaded to tmp */
if(is_uploaded_file($_FILES['articleImage']['tmp_name'])) {
echo "Error : the file didn't upload";
die();
}
/* Checking file doesn't already exist */
$imagePath = "img/articles/".$_FILES['articleImage']['name'];
if(file_exists($imagePath)) {
echo "Error : the filename is already taken";
die();
}
/* Writing image */
if(!move_uploaded_file($_FILES['articleImage']['tmp_name'], $imagePath)) {
echo "Error : the file coundn't be written";
die();
}
echo 'Success';
die();
?>
The request is correctly sent :
-----------------------------45933353531894573431775954628
Content-Disposition: form-data; name="articleImage"; filename="my_file.png"
Content-Type: image/png
[image content]
-----------------------------45933353531894573431775954628--
But I still get the "file didn't upload" error...
As I mentionned earlier, I did check my php conf (edited the correct php.ini file with /tmp as upload_tmp_dir and set upload limits to 100M), and /tmp has 777 chmod on it.
What am I missing ?