雖然試圖使用形式和PHP/IIS 7上傳文件的臨時文件,我得到這個消息:無法創建,同時上傳
PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0
我的形式:
<form action="acciones.php" id="form3" method="POST" enctype="multipart/form-data">
<input type="hidden" value="3" name="accion">
<input type="text" name="nombre" placeholder="Nombre">
<input type="file" name="imagen" accept="image/x-png, image/gif, image/jpeg" />
<input type="button" id="envio" class="button azul" value="Agregar" onclick="envios()">
</form>
$target = "/images/";
$target = $target . basename($_FILES['imagen']['name']);
//This gets all the other information from the form
$name=$_POST['nombre'];
$pic=($_FILES['imagen']['name']);
//Writes the information to the database
$query = "INSERT INTO Playeras (Nombre, Ruta) VALUES ('$name', $pic')";
mysql_query($query, $conexion -> conn) or die("Error: ".mysql_error()) ;
//Writes the photo to the server
if(move_uploaded_file($_FILES['imagen']['tmp_name'], $target))
{
//Tells you if its all ok
echo "The file ". basename($_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
}
else
{
//Gives and error if its not
echo "Sorry, there was a problem uploading your file.";
}
我設置的路徑爲臨時文件:
upload_tmp_dir = "C:/Users/server/Pictures/tmp"
併爲IIS_IUSRS和IUSRS提供了總控制權限。但每一次,我都會得到這個錯誤。我不知道我做錯了什麼。如果有人能幫助我,那會很好。
您是否已經創建了tmp目錄?嘗試創建tmp目錄來解決問題。 – soachishti 2013-05-10 19:06:24
肯定的,它的存在,並具有權限 – aerojun 2013-05-10 19:09:41
嘗試從PHP代碼的ini_set設置臨時路徑( 「upload_tmp_dir」, 「C:/用戶/服務器/圖片/ TMP」);或ini_set(「upload_tmp_dir」,「server/Pictures/tmp」); – soachishti 2013-05-10 19:36:38