非常感谢这里的一些帮助。我一整天都在努力将图像上传到运行 Zeus 的共享主机(而不是 apache——是的,我知道,它们正在改变!)。主持人责备代码但不会告诉我为什么“因为他们不是程序员”我尝试了这么多不同版本的表单脚本,我没有选择。我当然检查了 php ini 文件配置的上传限制(主机不允许我更改),它们都是 128meg。所以看起来这不太可能是原因。脚本的结果是我们得到最终的“成功加载文件”消息,但加载的文件大小为零(因此目标目录中没有新内容)。我对 php 比较陌生,所以请在行话上放轻松。谢谢你。
这是两个文件>>首先是表格...
<form enctype="multipart/form-data" action="anewupload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
以及表单引用的php文件...
<?php
$target = "uploads/";
$target = $target . basename( $_FILES['uploaded']['name']) ;
$ok=1;
//This is our size condition
if ($uploaded_size >350000)
{
echo "Your file is too large.<br>";
$ok=0;
}
//This is our limit file type condition
if ($uploaded_type =="text/php")
{
echo "No PHP files<br>";
$ok=0;
}
//Here we check that $ok was not set to 0 by an error
if ($ok==0)
{
Echo "Sorry your file was not uploaded";
}
//If everything is ok we try to upload it
else
{
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded to..";
echo $target;
echo "..The uploaded file size is $uploaded_size";
}
else
{
echo "Sorry, there was a problem uploading your file.";
}
}
?>