我在这里有一个有趣的 - 我在我的Mac和Windows笔记本电脑上运行本地安装的MAMP。使用我本地版本的Windows上完全相同的文件,图像上传的代码工作正常,但是当我在Mac上运行相同的东西时,我会在线上获得错误未定义索引...
错误是指$_FILES['image']['tmp_name'];
$filename = date("Y-m-d_H-i-s").'-'.$_FILES['image']['tmp_name'];
$dest = '../uploads/';
// Check for errors
if($_FILES['file_upload']['error'] > 0){
die('An error ocurred when uploading.');
}
if(!getimagesize($_FILES['file_upload']['tmp_name'])){
die('Please ensure you are uploading an image.');
}
// Check filetype
/*
if($_FILES['file_upload']['type'] != 'image/png', 'image/jpg', 'image, jpeg'){
die('Unsupported filetype uploaded.');
}
*/
// Check filesize
if($_FILES['file_upload']['size'] > 500000){
die('File uploaded exceeds maximum upload size.');
}
// Check if the file exists
if(file_exists('../uploads/' . $_FILES['file_upload']['name'])){
die('File with that name already exists.');
}
// Upload file
if(!move_uploaded_file($_FILES['file_upload']['tmp_name'], $dest . $filename)){
die('Error uploading file - check destination is writeable.');
}
确实很奇怪?
答案 0 :(得分:0)
所以我发现我正在使用[image]
我应该使用[file_upload]