<?
if(isset($_POST['submit'])){
$url = 'http://www.connectedcampus.org/ckeditor/images/uploads/';
if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name'])))
{
$message = "No file uploaded.";
}
else if ($_FILES['upload']["size"] == 0)
{
$message = "The file is of zero length.";
}
else if (($_FILES['upload']["type"] != "image/pjpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png"))
{
$message = "The image must be in either JPG or PNG format. Please upload a JPG or PNG instead.";
}
else if($_FILES["file"]["size"] > 1000000){
$message = "File size too big!";
}
else if(file_exists($url.$_FILES["file"]["name"]))
{
$message=$_FILES["file"]["name"] . " already exists. ";
}
else if (!is_uploaded_file($_FILES['upload']["tmp_name"]))
{
$message = "Invalid File!";
}
else {
$message = "success!";
$move = move_uploaded_file($_FILES['upload']['tmp_name'], $url.$_FILES['upload']['name']);
echo $_FILES['upload']['tmp_name']."<br>";
echo $url.$_FILES['upload']['name'];
if(!$move)
{
$message = "Error moving uploaded file.";
}
$url = $url.$_FILES['upload']['name'];
}
echo $message;
</script>";
}
?>
這版畫 「錯誤移動上傳的文件」 這意味着move_uploaded_file($ _ FILES [ '上傳'] [ 'tmp_name的值'],$網址。$ _ FILES [ '上傳'] ['名']) 返回false。但我肯定是500%,我已經正確創建了http://www.connectedcampus.org/ckeditor/images/uploads/文件夾....那麼爲什麼會出現錯誤?PHP圖片上傳奇怪的問題
好了,現在改爲:
$url = 'bloguploads/';
if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name'])))
{
$message = "No file uploaded.";
}
else if ($_FILES['upload']["size"] == 0)
{
$message = "The file is of zero length.";
}
else if (($_FILES['upload']["type"] != "image/pjpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png"))
{
$message = "The image must be in either JPG or PNG format. Please upload a JPG or PNG instead.";
}
else if($_FILES["file"]["size"] > 1000000){
$message = "File size too big!";
}
else if(file_exists($url.$_FILES["file"]["name"]))
{
$message=$_FILES["file"]["name"] . " already exists. ";
}
else if (!is_uploaded_file($_FILES['upload']["tmp_name"]))
{
$message = "Invalid File!";
}
else {
$message = "";
$move = move_uploaded_file($_FILES['upload']['tmp_name'], $url.$_FILES['upload']['name']);
if(!$move)
{
$message = "Error moving uploaded file.";
}
$url = $url.$_FILES['upload']['name'];
}
echo $message;
</script>";
?>
現在的問題是,它說: 「已經存在」。爲什麼?我可以通過ftp客戶端看到文件尚未上傳
讀/寫權限可能? – hjpotter92 2012-04-01 08:00:09
@ hjpotter92 chmod($ _ FILES ['upload'] ['tmp_name'],777); $ message =「success!」; $ move = move_uploaded_file($ _ FILES ['upload'] ['tmp_name'],$ url。$ _ FILES ['upload'] ['name']); &更改上傳文件夾的權限以及...沒有任何作品 – 2012-04-01 08:23:28
它說「已存在」,而不是「Filename.jpg已存在」的事實應該是一個提示... – 2012-04-01 10:05:46