使用 Expression Web,希望将图像上传到我的网页,即使是用脚本编写的,也不会收到错误消息。将上传文件夹设置为与所有人共享。 php.ini
设置为file_uploads=on;upload_max_size=128M
。在 Firefox 上,脚本超时,在 IE 上“Internet Explorer 无法显示页面”。
几个星期以来,我一直在寻找答案。即使我是 php 的新手,我尝试过的所有其他脚本都可以正常工作。这个上传的事情让我摸不着头脑。最近的上传脚本尝试:
if (isset($_POST['submitted'])) {
// Check for an uploaded file:
if (isset($_FILES['upload'])) {
// Validate the type. Should be JPEG or PNG.
$allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');
if (in_array($_FILES['upload']['type'], $allowed)) {
$target_path = "C:/uploads/";
$name=$_FILES['upload']['name'];
$error=$_FILES['upload']['error'];
$tmp_name=$_FILES['upload']['tmp_name'];
if($error==UPLOAD_ERR_OK){
if($_FILES['upload']['size']>0){
move_uploaded_file($tmp_name, $target_path.$name);
print ("The file ".$name." has been uploaded.\n");
} else{
print ("There was an error uploading the file, please try again!\n");
}
}elseif ($error==UPLOAD_ERR_NO_FILE) {
print("No files specified.\n");
}else{
print("Upload failed.\n");
}
print("\n");
}//End of !in_array IF.
} // End of isset($_FILES['upload']) IF.
} // End of the submitted conditional.
?>
<div>
<form action="photogallery.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="524288" />
<p><b>File:</b><input name="upload" type="file" /></p>
<input name="submit" type="submit" value="Submit" />
<input name="submitted" type="hidden" value="TRUE" />
</form>
</div>
我正在尝试将图像上传到我目录中的上传文件夹中,然后显示在我的网页上。我已手动将图像放入文件夹,它们将通过链接显示在我的网页上,但使用这些脚本无法正常工作。我的网站没有上线,它正在开发中,我正在使用 XAMPP 和 Microsoft 开发服务器。