I have a script that uploads files fine on my local server running MAMP but when I upload it I get no file upload. I have tried to simplify as much as possible to troubleshoot and came up with the following script:
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
define('BASE_DIR', '/home/lineligh/public_html/Art3/');
define('IMG_UPLOAD_DIR',BASE_DIR.'artwork/');
$id='4';
print_r($_FILES);
if (isset($_FILES['picture']['name'])) {
//check size
if ($_FILES['picture']['size'] > 900000) {
$uploaderr = true;
$uploaderrmsg.='File must be less than 900,000 bytes<br />';
}
//check type
if ($_FILES['picture']['type'] != "image/jpeg" && $_FILES['picture']['type'] != "image/png") {
$uploaderr = true;
$uploaderrmsg.='File must be a jpeg or png<br />';
}
$uploaddir = IMG_UPLOAD_DIR;
$uploadfile = $uploaddir . $id . '.' . end((explode(".", $_FILES["picture"]["name"])));
$result = move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile);
echo '<br>'.$_FILES['picture']['tmp_name']."</br>";
echo $uploadfile;
echo '<br>$result: '.$result;
}
?>
Which produces the following output:
Array ( [picture] => Array ( [name] => Olivia-IMG_8678.jpg [type] => image/jpeg [tmp_name] => /tmp/phpe5Vpyq [error] => 0 [size] => 192649 ) )
/tmp/phpe5Vpyq
/home/lineligh/public_html/Art3/artwork/4.jpg
$result: 1
So, the file gets to the server, the move_uploaded_file function claims that it successfully renames the file and puts it in /home/lineligh/public_html/Art3/artwork/ but if I look for the file it is not there. I'm stumped as to what else to check. Webhosting company swears that my permissions are correct.