[英]move_uploaded_file / No such file or directory in PHP
i have a problem with the move_uploaded_file function this is the problem: 我对move_uploaded_file函数有问题,这是问题所在:
Warning: move_uploaded_file(/imagenes/Icon.png) [function.move-uploaded-file]: failed to >open stream: No such file or directory in /home/decc98/public_html/php/insert.php on line 6 警告:move_uploaded_file(/imagenes/Icon.png)[function.move-uploaded-file]:无法打开流:第6行的/home/decc98/public_html/php/insert.php中没有此类文件或目录
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpIBBh5U' >to '/imagenes/Icon.png' in /home/decc98/public_html/php/insert.php on line 6 警告:move_uploaded_file()[function.move-uploaded-file]:无法在第6行的/home/decc98/public_html/php/insert.php中将'/ tmp / phpIBBh5U'>移动到'/imagenes/Icon.png'
Insercion exitosa 插入昆虫
Other stuff, i speak spanish so part of my code is in spanish... Anyways, my code is: 其他的东西,我说西班牙语,所以我的代码的一部分是西班牙语的...总之,我的代码是:
<?php
include "conexion.php";
$ruta = "/imagenes";
$archivo = $_FILES['imagen']['tmp_name'];
$nombreArchivo = $_FILES['imagen']['name'];
move_uploaded_file($archivo,$ruta."/".$nombreArchivo);
$ruta=$ruta."/".$nombreArchivo;
$texto = $_POST['descripcion'];
$id = rand(1,200);
$insertar = mysql_query("INSERT INTO tablaUno VALUES('".$id."','".$ruta."','".$texto."')");
if ($insertar) {
echo "Inserción exitosa";
}else{
echo "Fallo en la inserción";
}
?>
Please if anyone can help me I would appreciate it! 请任何人能帮助我,我将不胜感激!
You need to use a relative path instead of an absolute path. 您需要使用相对路径而不是绝对路径。
For example: 例如:
$ruta = "imagenes";
leaving out the /
at the beginning of your folder name, if you're using your script from the root. 如果您从根目录使用脚本,则在文件夹名称的开头保留/
。
Or, something like: 或者,类似:
$ruta = "../imagenes";
depending on the script execution's location. 取决于脚本执行的位置。
Note: Using /
is mostly used for an (server) absolute path, something to the affect of: 注意:使用/
主要用于(服务器)绝对路径,这会影响以下内容:
/var/user/user123/public_html/imagenes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.