2013-01-22 139 views
0

我試圖調整圖像,然後將其上傳到服務器(又名上傳文件,名爲「upload」),並找到了一個php大小調整圖像的教程http://www.white-hat-web-design.co.uk/blog/resizing-images-with-php/.I試圖將它與我的上傳功能集成,但圖像不會改變。我能做些什麼來解決它? 我使用PHP 5.3和HeidiSQL。PHP錯誤,圖像調整大小

error_reporting (E_ALL^E_NOTICE); 
$allowedExts = array("jpg", "jpeg", "gif", "png"); 
$parts = explode('.', $_FILES["file"]["name"]); 
$extension = end($parts); 
if ((($_FILES["file"]["type"] == "image/gif")|| ($_FILES["file"]["type"] == "image/jpeg")|| ($_FILES["file"]["type"] == "image/png")|| ($_FILES["file"]["type"] == "image/pjpeg"))&& in_array($extension, $allowedExts)){ 
if ($_FILES["file"]["error"] > 0){ 
$mesaj= "Return Code: " . $_FILES["file"]["error"] . "<br />"; 
} 
$nume= $_FILES["file"]["name"]; 
if (file_exists("../upload/" . $_FILES["file"]["name"])){ 
$mesaj= $_FILES["file"]["name"] . " already exists. "; 
} 
else{ $image = new SimpleImage(); 
$image->load($_FILES['file']['tmp_name']); 
$image->resizeToWidth(150); 
move_uploaded_file($_FILES["file"]["tmp_name"], 
"../upload/" . $_FILES["file"]["name"]); 
$mesaj= "Stored in: " . "upload/" . $_FILES["file"]["name"]; 
mysql_query("INSERT INTO imagini (nume) VALUES ('$nume')"); 
} 
} 
<form action="<?php $_PHP_SELF ?>" method="post" enctype="multipart/form-data"> 
    <label for="file">Poza</label><input type="file" name="file" /> 
    <input type="submit" value="Adauga imagine" class="buton_imagine" /> 
</form> 

回答

0

move_uploaded_file($_FILES["file"]["tmp_name"], "../upload/" . $image);

$image是你的目標,你需要改變$image$_FILES['file']['name']