Reputation: 1828
In my site, i have created functionality to upload MS-Word Document.
and i'm moving that file using following PHP function
move_uploaded_file($_FILES['upload_file']['tmp_name'],$path);
I just want to know What happens if file(word document) is open while uploading it?
does it create any problem or generate any error?
Upvotes: 0
Views: 217
Reputation: 1645
Text editors don't have any hold over files they have open - they load them into memory, then save them back out when you hit save. So no, there will be no problem if a file is open when it is being uploaded. I wouldn't worry about mid-upload saves either (re: @Joe) - trust the browser and OS to sort that out for you. In theory, any file could be modified during an upload, but in practice, doesn't happen.
Upvotes: 1
Reputation: 47649
Depends on how Word behaves. If it is in the middle of a write, then you'll either get a corrupted file or the OS will make the browser wait before uploading it. But this is a rare occurrence.
If the document is open, but Word is not currently writing you will either get an old version of the file, or a semi-saved corrupted state.
Best not risk it, and tell the user to close the file first.
Upvotes: 5