0

I want to upload file by using HTML + javascript.

Although it works, uploaded file name is path name not the file name.

Here is my code to upload file...

HTML

<form id="upload_form" method='POST' enctype='multipart/form-data' action='http://127.0.0.1:8080/upload?Name=' >
    file upload: <input type="file" id="file" name="file">
    <input type="submit" value="Submit" onclick="UploadFile()"/>
</form>

JavaScript

function UploadFile()
{
   document.getElementById("upload_form").action = document.getElementById("upload_form").action + _fileName; 
   document.getElementById("upload_form").submit();        
}

If I choose "C:\Users\Desktop\test5.txt"

The uploaded file name will be "C:UsersDesktoptest5.txt"

How can I change the file name to be "test5.txt" only

user5121761
  • 67
  • 1
  • 8

1 Answers1

0

Just reference here there are some tips for u to follow

http://stackoverflow.com/questions/2200100/input-type-file-for-ie-gives-full-path-need-file-name-only
user5121761
  • 67
  • 1
  • 8