Hello everyone,
So I have recently run into a conundrum with a script I am writing for someone. The script was written to upload a file, but when I go and execute it it doesn't want to move the file that was uploaded and returns no errors, warnings, or anything. And the array displays that everything is in order. Below is how the print_r of the $_FILES array looks:
Array ( [imagefile] => Array ( [name] => acoustic.JPG [type] => image/jpeg [tmp_name] => /tmp/php5J8rXy [error] => 0 [size] => 35694 )
As you can see, everything is there. Now, moving forward, below is my upload code. Like I said, it returns absolutely no errors, and the CHMOD is set up properly on the target directory. I am so frustrated with this script so any help would be appreciated. Thanks.
if ($_POST['action'] == "imageUpload") {
$imageFile = $_FILES['imagefile']['name'];
$imageFile_size = $_FILES['imagefile']['size'];
$imageFile_type = $_FILES['imagefile']['type'];
print_r($_FILES);
//Check to make sure the image is a GIF or a JPEG
if ($imageFile_type == "image/gif" || $imageFile_type == "image/jpeg" || $imageFile_type == "image/jpg" || $imageFile_type = "image/pjpeg")
{
if ($imageFile_size <= $_POST['MAX_FILE_SIZE'])
{
//Check to make sure the file does not exist
if (file_exists("$imageDir" . $imageFile))
echo "The file already exists, please delete the existing image before uploading a new one.";
else
{
//Insert the file into the database
$insertQuery = "INSERT INTO picture ( `id`, `picture_name` ) VALUES ( '{$_REQUEST['id']}', '{$imageFile}' )";
$query = mysql_query($insertQuery);
//Upload the file
move_uploaded_file($_FILES['imagefile']['tmp_name'], "$imageDir/$imageFile");
}
}
else
{
echo "Error: This image exceeds the maximum file size of 40 MB.";
}
}
else
{
echo "Error: This image must be of type GIF or JPEG.";
}
}