Not getting full path from file - javascript

Hello when ever i try to retrieve the full path of the browsed file by using *
request.getParameter()
***only the file name is being returned to the next jsp file.
Can someone help me..
Thanks in advance

When you upload a file you will get only the File Name and not the entire path that you see in the file upload field. This path is of user file system. If you want to save the file, you need to save it in server side directory path.

Related

How to get edited file path in Node.js

I am trying to get the file edited time in Node.js
There is a way to get the certain file edited time.
For example if I know the file path, then I can get the file edited time using fs.stat.
So I would like to know the path of file that just edited.
For example, If I edit file in D/New Folder how can I get that path?
Perhaps is it impossible?
If it is impossible what about ASP.NET?
Thanks

Upload a string as a text file to a server, js (node accepted too, I guess)

So, I have a firebase storage server, and I wish to store the path to every uploaded file inside a text file, for future reference. So, every time I upload a file, I will read my paths text file from the server, then add the latest path/string to it, then re-upload it. The only thing being is that I don't think we can upload a String to firebase just like that. How do I convert the modified string back into a file? Upon that, I do not know how to read data from the downloaded text file to, so any help would be highly appreciated.
Thanks!

File from node4excel to multer

I create an funciton to generating an xlsx file with node4excel library. This function work fine and generate me new files. But I want to save in database a link to this files. I try using multer from express-multer but it does not work and do not save me files in multer destination.
my code:
//multer function
#UseInterceptors(FileInterceptor('files', multerOptions))
uploadFile(#UploadedFile() file){
console.log(file);
}
//generating new file with excel4node
workBook.write('files.xlsx')
//trying to save this file with using multer
this.uploadFile(workBook.write('raport.xls'));
but it not work :/
can someone tell me how to create an link to new files which can be stored in ./files folder?
To save excel file you need to follow points below
just use node4excel to create the file
then save this file with workBook.write('xxxx.xlsx'). but you need to change xxxx.xlsx to workBook.write(`${uuid_v4}.xlsx`). why we use uuid_v4 as file name ? to overcame overridning old file when save new file with same name
now we have excel file with unique name saved in specific path in own server. let's say full path for this file is /app/data/files/5fe3cc43-e1c3-4c1d-a907-b1636b57a892.xlsx. remember to save file in this path you need to use workBook.write(`/app/data/files/${uuid_v4}.xlsx`).
now we missing some thing how to download it ? simply we save file name in database like fileName: "5fe3cc43-e1c3-4c1d-a907-b1636b57a892.xlsx". after save it we use the same uuid_v4 to save file name in database.
now we need to create endpoint exposed to user. when request to it with file name we will check if this user have permission to download this file if ok we will send this file to him. so we need user to send the filename to know what file he need, token to check permission (identify this user).
so you didn't need to use multer. multer help you to upload file not create file then sent it to client.
NOTE: All points above around Node.js (backend).

How to read content from a file , uploaded using "Input Type" = file in HTML

I have a simple HTML form, where I have a field with browse button for uploading local files.
When fetching the uploaded file's path, it is showing as C:/fakepath/filename.xls. I came to know that it is the browser security that is not allowing to read exact file path from local Computer.
Is there any way that I can read contents from the Uploaded file.
<input type="file" id = "FilePath" name="FilePath" size="18">
So when I do document.getElementById("FilePath"). I got C:/fakepath/filename.xls.
Can anyone please help how to read file content from uploaded file
You're looking for the HTML5 File API.
you can use the following URL as a reference to read the file using js.
reference

Img upload on opencart

I`m trying to add pictures to reviews on opencart products.
I use jquery.form.js (from here)
I get the name of the file(C:fakepath/Image.png),but I cant proceed from there.I cant figure our there exactly is this file located on the server.
Any help will be appreciated!
C:fakepath/Image.png is the path generated by browsing on windows when you are uploading the image with a input type file. You need to post the image on the server to get your image server path.

Categories

Resources