Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error using rename function in PHP

Tags:

php

I keep getting this error, although the file still gets moved into the correct directory. Anybody know why i'm getting this error?

Warning: rename(../Images/uploaded/1162504_56863010.jpg,../Images/uploaded/Portraits/1162504_56863010.jpg) [function.rename]: No error in D:\Data\Websites\wamp\www\StephsSite\PHP\addImage.php  on line 21
like image 841
Catfish Avatar asked Feb 11 '26 16:02

Catfish


1 Answers

According to the User Contributed Notes to rename(), there are issues on Windows systems when the target file already exists.

  • try unlink() ing the target file first if it exists
  • Alternatively, try copy()
like image 90
Pekka Avatar answered Feb 13 '26 06:02

Pekka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!