Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get uploaded file content with Javascript

Is it possible to upload a user file and pass its content to a textarea using javascript/jquery?

like image 305
Philipp G. Sinicyn Avatar asked Nov 27 '25 19:11

Philipp G. Sinicyn


2 Answers

Yeah, it's possible.

  1. Upload the file using post to a url for ex. http://a.b/c
  2. Read the file at the server side. Lets suppose you have another URL such as http://a.b/getcontent which reads that file at server side & replies with the content.
  3. You send an AJAX request to /getcontent URL and receive the reply.
  4. Change the HTML using javascript accordingly.
like image 105
Abhijeet Rastogi Avatar answered Nov 29 '25 08:11

Abhijeet Rastogi


I think this open-project should be all you need. It's a JQuery-based file uploader. http://blueimp.github.com/jQuery-File-Upload/

Once you have it uploaded, store it in wherever you store it (i.e. your database) and get it back via a JQuery ajax query.

like image 26
Greg Kramida Avatar answered Nov 29 '25 09:11

Greg Kramida



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!