On 7/10/2013 1:21 PM, Ajay Garg wrote:
Hi all.

I have a requirement, wherein I need to allow vanilla uploads of files
to a HTTPD server.

Any client can upload any number of files (one at a time).
Also, there is just one directory, where the files get stored
"finally" (that is, after being copied from the temporary location,
via "move_uploaded_file")

Also, I have been able to get the simple file uploading running via
PHP, by picking up one of the numerous "Hello World" examples
available :)



Now, I am facing the following use-case ::

1)
User 1 starts uploading a large file, say "big_file.avi".

2)
Meanwhile, user 2 also starts uploading a (different) file, but with
the same name "big_file.avi".


In an ideal scenario, user 2 should be prompted with a message, that a
file of the same name is already being uploaded by someone else
somewhere.
Is there a way to do this?

( Note that, had the user 2 started uploading AFTER user 1 had
finished with the upload, we could probably modify the PHP-script at
the sever-side, to let user-2 know that a file of the same name
already exits. But I am failing to find a solution, when the user 2
starts the upload WHILE the large file of user 1 is in the process of
completing uploading).


Any way the issue may be solved?

I will be grateful for any pointers :)



Regards,
Ajay

The problem is not of PHP's making. It is something that you have to program around. Is the user determining the filename to be used? If so, then you need to check for that name before doing you "move". If it's a duple, then create a temporary name in your final place, hide it in the user's page and send it back to him with a message to change his name.

If the user is NOT determining the name, then your normal process would be to pick an unused name I presume and send That back to the user anyway, so problem never happens.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to