我想用PHP將文件上傳到服務器。我無法讓它工作。下面是代碼:在php中上傳文件的問題
if(isset($_POST['Upload']))
{
//size condition
if ($_FILES['uploaded']['size'] > 350000)
{
$mesg = "Your file is too large.<br>";
exit;
}
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], "upload/" . $_FILES['uploaded']['name']))
{
$mesg = "The file ". basename($_FILES['uploaded']['name']). " has been uploaded";
}
else
{
$mesg = "Sorry, there was a problem uploading your file.";
}
}
else
{
$mesg = "Select a File to upload.";
}
這裏是我使用的文件提交表單的代碼:將上傳
<?
echo $mesg;
?>
<br /><br />
<form enctype="multipart/form-data" action="" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
+1優秀的安全保護點 – 2009-06-09 00:09:55
這是一個密碼保護區,只有2或3人可以訪問所以我不擔心惡意腳本。 – 2009-06-09 00:11:55
我添加了enctype =「multipart/form-data」,但我仍然遇到同樣的問題 – 2009-06-09 00:13:43