?
Solved

Check if a file has been selected with BlueImp's JQuery File Upload

Posted on 2013-12-29
1
Medium Priority
?
2,111 Views
Last Modified: 2014-01-11
Hello, I'm using BlueImp's JQuery File Upload plugin (https://github.com/blueimp/jQuery-File-Upload) and although everything is working properly I don't know how to check if the input has a file. How can I do this?

This is my html:

<span class="btn fileinput-button">
    <i class="icon-camera"></i>
    <input id="filUserNewPostImageUpload" name="file" type="file" />
</span>

Open in new window


This is the jquery:

$("#filUserNewPostImageUpload").fileupload({
   url: "/userattachment/upload/",
   dataType: "json",
   start: function(e){
      $("#hidUserNewPostAttachment").val("");
   },
   done: function (e, data) {

      if(data.result.result == "success"){
         // This returns an empty string even when a file has been uploaded successfully
         console.log($("#filUserNewPostImageUpload").val());  
      }
   }
});

Open in new window


Thanks!
0
Comment
Question by:ivanblue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39744695
What about :
    change: function(e) {
        alert("file change");
    }

Open in new window


$("#filUserNewPostImageUpload").fileupload({
   url: "/userattachment/upload/",
   dataType: "json",
   start: function(e){
      $("#hidUserNewPostAttachment").val("");
   },
   done: function (e, data) {

      if(data.result.result == "success"){
         // This returns an empty string even when a file has been uploaded successfully
         console.log($("#filUserNewPostImageUpload").val());  
      }
   },
    change: function(e) {
        alert("file change");
    }
});

Open in new window

0

Featured Post

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question