Hey guys, I created this system of instant messaging now i want to upload and send a file to another user. I am using php and javascript. How to do so? Ok imagine that i am a user chatting for instance with you, now i want to send you a file how can i do it using php. I understand that it is two steps upload the file and then send? Is that开发者_StackOverflow社区 right?
You should have on client A a classic uploader that will upload file to a specific directory for the chat session, then when upload is complete show to client B a message/link in the chat that a file is available for download.
Hey ! You have made a FTP over HTTP ;) Your server will be the exchange platform.
The steps should be:
- Bob and Alice are in chat.
- Bob click the
Browse
button and select a file. - The file is uploaded to the server using standard PHP upload script.
- The file is being validated, and only if valid continue to next step. (e.g. no executable, maybe virus scan)
- The file is saved in secure location outside the website root, with unique ID.
- Alice see system message "Bob has sent you a file" with link to PHP proxy file e.g.
download.php?id=[the unique ID assigned in previous step]
- The file
download.php
will verify the user requesting it match the recipient of the uploaded file according to the given ID and if matching, send the file to the browser to invoke download.
精彩评论