1

I want to get file name after user uploading file in same page.

How could I do ?

Please give me some advices.

Here is my simple code.

<html>
<head>

<script type="text/ecmascript" src="../_js/jquery.min.js"></script> 
<script type="text/ecmascript" src="../_js/jquery-ui.min.js"></script>
<!-- Upload File -->
<link href="http://hayageek.github.io/jQuery-Upload-File/uploadfile.min.css" rel="stylesheet">
<script src="http://hayageek.github.io/jQuery-Upload-File/jquery.uploadfile.min.js"></script>

<script>
$(document).ready(function() {

    var extraObj = $("#drop").uploadFile({
        url:"fileupload.php",
        fileName:"myfile",
        autoSubmit:false
    });

    $("#submit").click(function() {
        //alert(I want get file name here);
        extraObj.startUpload();
        return false;
    });
});
</script>
</head>
<body>

    <div id="drop" type="file">Upload File</div>
    <form role="form" method="post" action="">
        <button id="submit" type="submit" class="btn">Send</button>
    </form>

</body>
</html>

Thanks a lot.

Neishil
  • 57
  • 1
  • 8
  • Can you check [this link](https://stackoverflow.com/questions/31127350/how-to-get-filename-on-html-javascript-jquery-drag-drop-event-non-html5) – Madhavan.V Nov 30 '17 at 06:46
  • Thanks for your comments. I find other method to get file name. I use onSuccess:function http://hayageek.com/docs/jquery-upload-file.php#single – Neishil Dec 01 '17 at 00:49

1 Answers1

0

console.log(data.originalFiles[0].name) Please use this.

Jordan Micle
  • 59
  • 1
  • 8
  • 1
    Welcome to SO. When you give an answer, please, try to give some explanation as the user is trying to know what to do, not just one line of code. – David García Bodego Oct 17 '19 at 11:47