简体   繁体   中英

can not move file using rename

I have a tmp folder for holding the temperary uploaded photos and after the user click the save button, the photos would be moved to a new folder.

 $ori=$tmp_prefix.$select_array['photo']; //../user_data/tmp_chron/tmp_chronicle/kesongxie/HZi7DkRMvEIa6qc/22.jpg, this is the original files in temparary folder
   $new=$prefix.$select_array['photo']; //../user_data/chron/chronicle/kesongxie/HZi7DkRMvEIa6qc/22.jpg , this is the folder I want to move to
    rename($ori,$new);

I cannot move the files to another folder, it gives me a warning without any detail suggested

warning:rename(../user_data/tmp_chron/tmp_chronicle/kesongxie/HZi7DkRMvEIa6qc/22‌​.jpg,../user_data/chron/chronicle/kesongxie/HZi7DkRMvEIa6qc/22.jpg ) on edit.php line 34

在移动文件之前创建父目录

mkdir(dirname($new), 0777, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM