Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use move_uploaded_file more than once

I call the move_uploaded_file on my code twice but seems that the second one doesn't work.

If I interchange the position of them,

then first one will works, but the second won't.

any suggestion?

like image 386
Samsan Phone Number Lookup Avatar asked Feb 01 '26 08:02

Samsan Phone Number Lookup


2 Answers

You can't move a file twice. Perhaps you are looking for copy(). When you move the file, the original doesn't exists anymore.

Docs: http://php.net/copy

You could use move_uploaded_file and copy the file from there again

like image 124
Rene Pot Avatar answered Feb 03 '26 20:02

Rene Pot


Form PHP manual: move_uploaded_file — Moves an uploaded file to a new location

If I understand right, what you probably do is that when you first call move_uploaded_file function you move the uploaded file into a new location, then when you call move_uploaded_file function the second time the function does nothing because the file is moved already.

like image 42
Mihai V Avatar answered Feb 03 '26 20:02

Mihai V



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!