我正在复制网站及其数据库结构。除了上传图片外,一切都很好。用户可以登录并上传图片作为帐户图片。当代码执行时,我只是得到一个空白的屏幕,并且必须重新开始。有什么想法吗?这是我正在使用的代码:
// make a note of the location of the upload form
$uploadForm = 'http://' . $_SERVER['HTTP_HOST'] . $directory_self .'editprofile.php'; //Working
$photourltest=$_FILES['photourl'];
if (($_FILES['photourl']['type'] != 'image/jpeg') && ($_FILES['photourl']['type'] != 'image/pjpeg')) {
$photo=$_POST['photo'];
if ($photo == "") {
$photo = "http://www.somekindofsite.com/id/images/keys.jpeg";
}
} else if ($_FILES['photourl']['error'] > 0) {
echo 'Problem : ';
switch ($_FILES['photourl']['error'])
{
case 1: echo 'File exceeded upload_max_filesize';
echo "Please press the back button to re-edit";
break;
case 2: echo 'File exceeded max_file_size';
echo "Please press the back button to re-edit";
break;
case 3: echo 'File only partially uploaded';
echo "Please press the back button to re-edit";
break;
case 4: echo 'No file uploaded';
echo "Please press the back button to re-edit";
break;
case 6: echo 'Cannot upload file: No temp directory specified';
echo "Please press the back button to re-edit";
break;
case 7: echo 'Upload failed: Cannot write to disk';
echo "Please press the back button to re-edit";
break;
}
//exit;
} else {
//put photo into directory
$directory_self = str_replace(basename($_SERVER['PHP_SELF']), '', $_SERVER['PHP_SELF']);
$uploadsDirectory = $_SERVER['DOCUMENT_ROOT'] . $directory_self . 'images/'; //*
$upfile = $uploadsDirectory.$_FILES['photourl']['name'];
$photo = 'http://www.somekindofsite.com/images/' .$_FILES['photourl']['name'];
//moves the file to its final location and allocate the new filename to it
@move_uploaded_file($_FILES['photourl']['tmp_name'], $upfile)
or error ('recieving directory insufficient permission', $uploadForm);
}
答案 0 :(得分:0)
您在所提供的代码末尾没有使用PHP函数error()
。这将导致PHP中的致命错误。通常这些是可见的,但我怀疑你关闭了错误报告,这将隐藏此消息。
Turn on error reporting查看您的错误消息。然后删除error()
并将其替换为有效的函数以解决您的问题。