【发布时间】:2013-05-05 12:37:41
【问题描述】:
在尝试使用表单和 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 目录来解决问题。
-
是的,存在并且有权限
-
尝试从 php 代码中设置临时路径 ini_set("upload_tmp_dir","C:/Users/server/Pictures/tmp");或 ini_set("upload_tmp_dir","server/Pictures/tmp");
-
只是没有运气。一直显示同样的错误。
-
你能分享一下$_FILES['imagen']的结果吗