PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm trying to upload an archived file and then unzip. I can get the exec() command to execute on the file after the file upload script full executes through a different .php file. But for some reason it doesn't work when the uploading is still happening...
Does anyone know a solution to this problem?
Do you have a session started before the exec?
If so try doing a session_write_close(); before calling the exec(), a note on http://php.net/manual/en/function.exec.php suggests this.
i was always under the impression that the webserver did
not even execute the php script until all uploads were complete.
but maybe this is caused by php copying the file from tmp
have you tried unzipping the file before moving it,
just unzip it right from the tmp directory?
maybe move_uploaded_file continues in the background until its finished,
and php just keeps parsing before it finishes copying the file from tmp
try sleep(1) right after the move_uploaded_file call.
using sleep imo isnt a good solution,
but if it works, it at least tells us something about whats going on.
I don't have any sessions running during the script. I tried the sleep () function rehfeld but that didn't produce different results. But I'm sure the path is correct for the unzip command. I copied and pasted the echoed results into another file and used the exec command and was successfully able to unzip and rm the file. I switched out move_uploaded_file for copy() but that didn't do anything. Same problem script uploads the file but doesn't move it. My php.ini file doesn't name a tmp directory for the uploaded files. If I did unzip it there where would it the unzipped file end up at. So in the end I dropped the move_uploaded_file and copy() and elected for this:
I guess the only question that remains is how do I return the name of the directory that is unzipped/tarred? How will I know what it is? Does anyone know how to do that with exec() or with shell commands?
Okay well here's how I did it. I sent the output from the shell into $archive_output. I looked at the array and determined the index to search for the string to the unzipped file. Then I can use $match to make further changes to it-- like changing owner. Anybody know of a better way?