开发者

Cakephp uploading an image, the tmp_name file is getting deleted before the script is done?

开发者 https://www.devze.com 2023-01-27 08:17 出处:网络
I have an html form that allows the user to browse for a file to upload. In the cakephp script, I use move_uploaded_file() to upload the file from the temp location to a location on the server.

I have an html form that allows the user to browse for a file to upload.

In the cakephp script, I use move_uploaded_file() to upload the file from the temp location to a location on the server.

move_uploaded_file($f开发者_运维技巧ile['tmp_name'], $url);

However, the file seems to be disappearing before the upload is complete:

move_uploaded_file(/img/recipes/5.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory [APP\app_controller.php, line 97]

move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\Windows\Temp\phpF25A.tmp' to '/img/recipes/5.jpg' [APP\app_controller.php, line 97]


I think it's telling you that the target does not exist. /img/recipes/5.jpg is hardly a valid directory to upload to on UNIX system, it's probably completely invalid on Windows.

You'll need to build an absolute path to save the file in (like C:\webroot\project\images\foo.jpg) instead of a URL.


It's complaining about the non-existence of /img/recipes/5.jpg, not the source file (that's uploaded by the user).

0

精彩评论

暂无评论...
验证码 换一张
取 消