2
I’m using the function move_uploaded_file
The first time I use it, I send a certain video to a temporary folder.
1
move_uploaded_file($_FILES['cadVideo']['tmp_name'], "temporario/" . 'temp-'.$_FILES['cadVideo']['name']);
Works perfectly!
Ok! After that, I do some other assignments and functions and again I need to use the move_uploaded_file
. It turns out that at this second point it no longer works.
2
move_uploaded_file($_FILES['cadVideo']['tmp_name'], "../../Aulas/{$sessao[0]}/{$sessao[1]}/{$sessao[2]}/".$_FILES['cadVideo']['name']);
At first I thought it might be some error related to directories or something like that, so I reviewed it and concluded that this was not the error. But it still didn’t work.
For test purposes I copied and pasted the same function (1) and put in place the (2) and to my surprise it didn’t work either.
I was intrigued by this, how can a function that works normally not work again a few lines of code after?
move_uploaded_file works only once in the file? If yes, how can I dodge this problem?
Yes, it works only once, because once moved it is no longer uploaded file. To avoid this, move with the normal PHP file functions instead of using the uploads specific. or move to the right place at once. move_uploaded_file is practically an operation only to "accept definitively" the upload taking from the temporary location and avoiding its disposal.
– Bacco
And what are these normal functions? It is not possible to move to the right place at once, the file goes through small treatment before.
– Bsalvo
use normal "move" even (rename directory part) http://php.net/manual/en/function.rename.php
– Bacco