I need some logical help there instead of coding. i have a php chat messaging application. its working fine for sending messages to users. but i wanted to add a file attachments feature so that a file can be attached with any message. So the procedure should be that before sending a message when user select a file to attach, it will first upload file through ajax and then when user press send button, it will link that uploaded file to the sent message.
Database structure is
messages
id | conversation_id | message | time | sender
attachments
id | message_id | file_name | file_path
Can anyone help me in making logic with it?