問題描述
我已經(jīng)完成了你的標(biāo)準(zhǔn)檢查(目錄是否在那里,權(quán)限設(shè)置是否足夠?qū)捤?,而且我很確定我已經(jīng)涵蓋了你標(biāo)準(zhǔn)的愚蠢的人類技巧.這是失敗的代碼:
I've done your standard checks (is the directory there, are lax enough permissions set), and I'm pretty sure I've covered your standard stupid human tricks. Here's the code that's failing:
move_uploaded_file($_FILES['image1']['tmp_name'], "/public_html/flashsale/assets/img/products/T".$_FILES['image1']['name']);
目錄在那里 - 我從 FileZilla 復(fù)制了路徑.我什至在 FileZilla 和 HostGator 控制面板上的文件管理器中將權(quán)限設(shè)置為 777.此代碼生成兩個(gè)警告:
The directory is there - I copied the path from FileZilla. I even set the permissions to 777, both in FileZilla and in the file manager on the HostGator control panel. This code generates two warnings:
留言:move_uploaded_file(/public_html/flashsale/assets/img/products/Tsirloin.jpg)[function.move-uploaded-file]:無法打開流:沒有那個(gè)文件或目錄
Message: move_uploaded_file(/public_html/flashsale/assets/img/products/Tsirloin.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory
消息:move_uploaded_file() [function.move-uploaded-file]:無法將/tmp/phpI5GZ3S"移動(dòng)到'/public_html/flashsale/assets/img/products/Tsirloin.jpg'
Message: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpI5GZ3S' to '/public_html/flashsale/assets/img/products/Tsirloin.jpg'
按照這個(gè)順序.所以,文件正在上傳,目錄存在并設(shè)置為777,我還能缺少什么?
In that order. So, the file is being uploaded, the directory exists and is set to 777, what else could I be missing?
推薦答案
你不需要把完整的目錄放到文件中.嘗試從您的鏈接中刪除 /public_html/flashsale/
并查看它是否有效.另外文件不需要777權(quán)限,我自己上傳文件到755權(quán)限的文件夾.
you do not need to put the full directory to the file. try to remove /public_html/flashsale/
from your link and see if that will work.
In addition, the file does not need to have 777 permission, I myself upload files to folders with 755 permissions.
此外,您可以在目標(biāo)目錄中使用 getcwd();
.該函數(shù)將為您提供移動(dòng)文件所需的目錄.來源
also, you can use getcwd();
in the directory your aiming to. the function will give you the directory that you need to use for moving your file. source
這篇關(guān)于move_uploaded_file() 無法打開流:沒有這樣的文件或目錄的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!