[英]Cannot upload file: move_uploaded_file(): Unable to move '/tmp/phpYpUvDT' to 'var/www/libreria
I already checked widely on SO and on the web but I was unable to sort this out and i'm feeling stuck.我已经在 SO 和 web 上进行了广泛检查,但我无法解决这个问题,我感到被困住了。
This is the PHP code (it's pretty raw) i'm using to show an upload button for book files:这是我用来显示图书文件上传按钮的 PHP 代码(非常原始):
$partpath = "var/www/libreria/lib-folder/";
if (isset($_POST['upload'])){
$file = $_FILES['file'];
$fileName = $_FILES['file']['name'];
$fileTmpName = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileError = $_FILES['file']['error'];
$fileType = $_FILES['file']['type'];
$fileExt = explode('.', $fileName);
$fileActualExt = strtolower(end($fileExt));
$allowed = array('epub', 'mobi', 'pdf');
if (in_array($fileActualExt, $allowed)){
if ($fileError === 0) {
if ($fileSize < 100000000) {
$fileDestination = $partpath.$fileName;
move_uploaded_file($fileTmpName, $fileDestination);
echo "Upload completato <br><br>";
} else {
echo "File too big <br>";
}
} else {
echo "Error with file: error code ".$fileError." <br>";
}
} else {
echo "You cannot upload this <br>";
}
}
And I keep getting error:而且我不断收到错误:
Warning: move_uploaded_file(var/www/libreria/lib-folder/Mongoose for Application Development.pdf): failed to open stream: No such file or directory in /var/www/libreria/lib-folder/index.php on line 42
Warning: move_uploaded_file(): Unable to move '/tmp/phpg36Ubt' to 'var/www/libreria/lib-folder/Mongoose for Application Development.pdf' in /var/www/libreria/lib-folder/index.php on line 42
I'm running an apache server on an Ubuntu localhost, and I already tried to do the following:我在 Ubuntu 本地主机上运行 apache 服务器,我已经尝试执行以下操作:
I don't know what to check or do anymore to be honest, and I would be thankfull if somebody could give me an hint on what i'm doing wrong.老实说,我不知道该检查什么或做什么,如果有人能给我提示我做错了什么,我将不胜感激。
Thanks to anybody that will spend a minute to read and answer:)感谢任何愿意花一分钟阅读和回答的人:)
It seems uploaded file has a filename that contains space characters.上传的文件似乎有一个包含空格字符的文件名。 Try replacing all spaces in $filename with "_" before calling move_uploaded_file.在调用 move_uploaded_file 之前尝试将 $filename 中的所有空格替换为“_”。
just a guess, but it seems your origin is not existing: Warning: move_uploaded_file(var/www/libreria/lib-folder/Mongoose for Application Development.pdf): failed to open stream: No such file or directory.只是一个猜测,但似乎您的来源不存在:警告:move_uploaded_file(var/www/libreria/lib-folder/Mongoose for Application Development.pdf):无法打开 stream:没有这样的文件或目录。 It seems, there is / missing, right before var:)似乎,/ 丢失,就在 var 之前:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.