Reputation: 13
I've been trying to rename an image file using php using this code.
$user_id = $_POST[user_id];
$old_image_name = $_POST[old_image_name];
$image_name = $_POST[image_name];
rename('/_img/user_memes/large/user_'.$user_id.'/'.$old_image_name.'', '/_img/user_memes/large/user_'.$user_id.'/'.$old_image_name.'');
The error I'm getting is-
"Warning: rename(/_img/user_memes/large/user_2/1524957_717357634955838_1917151587_n.jpg,/_img/user_memes/large/user_2/1524957_717357634955838_1917151587_n.jpg) [function.rename]: No such file or directory in /var/sites/o/oddmeme.com/public_html/_process/post_single_meme_edit.php on line 8"
The image is definitely there. I've tried removing the / at the start and trying a few different version but nothing has worked. I've also set permission to 777 so that shouldn't be a problem.
Upvotes: 0
Views: 1801
Reputation: 1877
First of all, you have an error in your code:
You are using twice the same path in your function with $old_image_name...
Fix that and tell us if it's working.
Upvotes: 2