I am trying to upload files in the backend and I am successfully done it but the problem is I am uploading the files in a folder. So I need to parse the files so I need to define the folder name so that the file can be parsed. How can I define the folder name?
Here is the code, The folder name is uploads, but when I try to parse the file it says Error: ENOENT: no such file or directory, open '/uploads/undefined-1647961709285.xlsx'
const worksheetsArray = xlsx.parse('/uploads/' + filename);
Related
how to load html file along with css file and javascrip file in node js by express?
when I enter localhost:8080\about, load the about us page that contain html,css and js.
for that in your main express js file, you are going to want to add this line at the top of the file
app.use(express.static(__dirname + '/pathToStaticFiles'));
pathToStaticFiles will be the path to your static file, (usually called assets or public). Then all your html files will read from that directory so if your file path for the css file is ./static/css/style.css the html file will call from ./css/style.css. Hope this helped.
hello there I am building a folder upload system with js and PHP
but I got an issue I'm not able to upload a folder that not contains any files
I use
<input type="file" id="picker" name="files" webkitdirectory multiple>
and for getting the file i use
$('input[type="file"]').on("change", function (e) {
let files = $(this).get(0).files;
console.log(files);
});
if a folder contains any file so I can easily access the folder using
files[i].webkitRelativePath
what is the problem
I'm just getting files that contain webkitRelativePath not getting the folders directly
so I'm not able to get any empty subfolders with this approach
can anyone tell me how to access folders directly without webkitRelativePath or anything else so I can handle empty subfolders
Currently, I can 'upload' my images onto my server with Multer but now, how can I serve that file? If I visit the path which is: http://localhost:3001/public/backend/public/uploads/user-admin-1556247519876.PNG, i get a 404 cannot get.
I feel like i'm just missing a single step but I can't spot my error.
To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.
For example, use the following code to serve images, CSS files, and JavaScript files in a directory named public:
app.use(express.static('public'))
Now, you can load the files that are in the public directory:
http://localhost:3000/images/kitten.jpg
http://localhost:3000/css/style.css
http://localhost:3000/js/app.js
http://localhost:3000/images/bg.png
http://localhost:3000/hello.html
Express looks up the files relative to the static directory, so the name of the static directory is not part of the URL.
I have this folder/directory 'x' in the public folder of my application.
Now I have path name till the folder i.e., /path/to/dir/x , but I don't know the names of the files in this directory. Now I need to provide URL links to the files in the html a tag's href attribute.
How do I list the name of the files in this directory?
Angular is a client side library. Getting files from file directories is a backend capability.
I'm trying to use this plugin. Everythings work fine, only uploading files won't work. I can create folders, create new files, but if i try to upload any file, it shows me that file is successful uploaded and there is no file.
http://screenshot.cz/HPQH1/
Have you any experience with this problem?
I had some problems with it too, but changing the path configuration in ..\filemanager\config\config.php to your server specific setup is probably key. On a server setup with a site root of e.g. /httpdocs you may end up with something like this:
$base_url = 'http://'.$_SERVER['SERVER_NAME'].'';
$upload_dir = '/source/images/'; // path from base_url to base of upload folder (with start and final /)
$current_path = '../../../../source/images/'; // relative path from filemanager folder to upload folder (with final /)
$thumbs_base_path = '../../../../source/thumbs/'; // relative path from filemanager folder to thumbs folder (with final /)
I had the exact same problem. I could create files and folders but not upload files. It turned out that it didn't had anything to do with the config.php. The problem for me was that when I uploaded the files to the server with ftp, the ../filemanager/upload.php got corrupted.
It happened every time I uploaded this file. No other file had any problem. By setting the ftp protocol to sftp, it got uploaded correctly and then the plugin worked perfectly. So if anyone has the same problem, take a look at the upload.php and see if it's corrupted.