-3

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?

hassanrrs
  • 73
  • 2
  • 8
  • If you're just getting started with PHP and want to build applications, I'd strongly recommend looking at various [development frameworks](https://www.cloudways.com/blog/best-php-frameworks/) to see if you can find one that fits your style and needs. They come in various flavors from lightweight like [Fat-Free Framework](https://fatfreeframework.com/) to far more comprehensive like [Laravel](http://laravel.com/). These give you concrete examples to work from and guidance on how to write your code and organize your project's files. – tadman Nov 14 '19 at 01:32
  • what type of logic you are asking for? – Amanjot Kaur Nov 14 '19 at 11:58

1 Answers1

1

If you are looking for uploading an image via ajax, you can check here

Ajax Upload image

Then you can process the image and upload it to the server.. you can get the path of that image via ajax and then add that path in Database when you submit the button. And let the user click the submit button only when ajax is completed.

Amanjot Kaur
  • 2,028
  • 4
  • 18
  • 33