Kevin Pei
Kevin Pei

Reputation: 5872

How to get the "value" of a upload input with jQuery

I know that this sends stuff to a php file and gets stuff returned from the php file as javascript:

 $.ajax({
   type: "POST",
   url: "phpfile",
   cache: false,
   data: datahere,
   dataType: "script"
 });

But... suppose "datahere" is a file from a input file element. How am I supposed to get the value or data from that upload input file element?

Upvotes: 3

Views: 453

Answers (2)

Steve Robbins
Steve Robbins

Reputation: 13812

 $.ajax({
   type: "POST",
   url: "phpfile",
   cache: false,
   data: $('.thisInput').val(),
   dataType: "script"
 });

Upvotes: 1

Nathan
Nathan

Reputation: 12000

Take a look at these plugins: 7 trusted ajax file upload plugins using jquery

Those are some AJAX file upload plugins. They might be what you need.

Upvotes: 3

Related Questions