Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to get a full local path.

but I cant get a path of a selected file.

file path gets fake path.

What I have tried:

 $('#uploadmultifile').click(function (e) {
       debugger;
       e.preventDefault();
       var fileUpload = document.getElementById("files");
       var filepath = fileUpload.value;
       var form = new FormData($('#fileupload')[0]);
       for (var i = 0; i < fileUpload.files.length; i++) {
           form.append('file', fileUpload.files[i]);
       }
       form.append('filepath', filepath);
       $.ajax({
           url: '/UplaodFile/uploadPgrs',
           type: 'POST',
           success: function (data) {
               alert("Data Uploaded: " + data);
           },
           data:form,
           cache: false,
           contentType: false,
           processData: false
       });
       return false;
});
Posted
Updated 19-Mar-18 2:25am

1 solution

You can't get the full path for security reasons. To preempt your next question, no there is no way around that.
 
Share this answer
 
Comments
Jaydeep Shah 19-Mar-18 9:14am    
I am trying to upload a file to amazon s3.
in this API required path of the file (filepath)
ie.
fileTransferUtility.Upload(filePath, existingBucketName);

https://docs.aws.amazon.com/AmazonS3/latest/dev/HLuploadFileDotNet.html

without file path, it's not working.
F-ES Sitecore 19-Mar-18 9:19am    
That assumes the code is running on the same machine the file exists on. In a web site scenario that's not true, the file is on the client PC and the code is running on the server. If you want to allow someone to upload a file to AWS via your site then have them upload the file using the upload component, you will then need to save that file to the website, then use Server.MapPath to get the location of that file on your web server, and now you can use the code in that link to upload from your web server to AWS.
Jaydeep Shah 19-Mar-18 9:25am    
in this situation what happened.
if 1 Gb file takes 25 min to upload.

first, i save to server and then Amazon so it will take double time.
Richard Deeming 19-Mar-18 11:21am    
Then you need to upload the file from the browser directly to Amazon, rather than trying to upload it to your server first:
Uploading Photos to Amazon S3 from a Browser - AWS SDK for JavaScript[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900