1
在php中上傳文件時,我無法上傳所有類型的文件,如果在無法下載的文件名之間存在任何空間。請任何人都可以糾正這個代碼在PHP中上傳文件時出錯
這裏是我上傳的代碼
<?php
$target_path = "../mt/sites/default/files/ourfiles/";
$target_path = $target_path . basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename($_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
$con = mysql_connect("localhost","mt","mt");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}else{
echo "Connected";
}
// Create table
mysql_select_db("mt", $con);
mysql_query("INSERT INTO mt_upload (FileName, FilePath)
VALUES ('".basename($_FILES['uploadedfile']['name'])."', '".$target_path.basename($_FILES['uploadedfile']['name'])."')");
// Execute query
mysql_query($sql,$con);
mysql_close($con);
?>
將標題重命名爲'PHP Upload filename with spaces problem *。'並把這個描述放在問題中。 – Egon 2009-10-21 06:50:51