Solved

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

Posted on 2013-12-29
1
2,078 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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
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)

687 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