使用php上载文件时出错
好的,我在过去的两天里使用了谷歌,没有发现我的代码有什么问题。首先,我似乎使用了错误的路径,但官方的Hilfe中心(如1&1的帮助中心)说,这一定是正确的路径e:\Kunden\Homepages\11\d12345678\www\UploadTest显然,您必须使其适应您的路径,这是我通过phpinfo获得的 因此,我使用以下代码:使用php上载文件时出错,php,Php,好的,我在过去的两天里使用了谷歌,没有发现我的代码有什么问题。首先,我似乎使用了错误的路径,但官方的Hilfe中心(如1&1的帮助中心)说,这一定是正确的路径e:\Kunden\Homepages\11\d12345678\www\UploadTest显然,您必须使其适应您的路径,这是我通过phpinfo获得的 因此,我使用以下代码: <form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">
<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">
<input type=\"file\" name=\"datei\"><br>
<input style=\"position:absolute;left:5px\" type=\"submit\" value=\"Hochladen\">
</form>
在php脚本运行upload.php的站点上。我在这里得到了另一个线程上的代码,并希望使用它进行故障排除。稍后我将回到我自己的代码
我现在犯了最后一个错误:
'文件上载过程中出错。请再试一次
我只想上传.txt文件,这些文件以后会在基于新闻的网站上使用。Thx为任何帮助提前 我认为问题在于输入的名称或文件变量的名称。
$files=$\u files['datei']['tmp\u name'] 您认为concat$upload_path的结果如何$文件名?我得到了e:\Kunden\Homepages\11\d12345678\www\UploadTestSO-$filename在哪里?您只打印了$upload\u path echo$upload\u path$文件名;所以我想说有问题吗?!让我检查一下,回声的结果是什么?
$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = "e:\\Kunden\\Homepages\\11\\d12345678\\www\\UploadTest";
$filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large.'); // if we upload large file then we get error.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.'); // if we have no enough permission then got error.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename)){
// if everything is fine then we upload file and go to somewhere else
header ('location: whereeveryouwantogo.php');
} else {
echo 'There was an error during the file upload. Please try again.';
}