When a user selects a directory from which to upload all documents, it might contain hidden files created by windows like thumbs.db
Is there any way of detecting, either on the front end or back end, whether a particular file was hidden?
Currently handling files uploads with bootstrap-vue and typescript
<b-form-file id="documentFolder"
accept="allowedFileTypes"
style="display:none;"
#change="handleFolderSelected"
:directory="true" />
handleFolderSelected(files: Array<File>) {
// build form data - post files
}
I assume its just using a regular file input, but can't see anything useful there either
I'm recieving the files as IFormFiles using .net-5.0
Is this possible at all, or do I need to simply inform the user that they should remove all hidden files?
Related
For a custom WordPress plugin, I'm trying to allow my users to select a folder and use it as the file download path.
Example: If the user selects the folder "C://Users/Kahiego/Desktop/img", may it be empty or not, when they'll try to download files from the plugin, everything will get downloaded in there.
So far all I can achieve right now is allowing to select a folder:
<form action="" method="post" enctype="multipart/form-data">
<input type="file" id="ctrl" webkitdirectory directory multiple/>
<input type="submit" value="Upload Image">
</form>
(but it will only count as a multiple file select). I checked on various posts already but none can tell me how to achieve this (with some saying they don't see how this could be useful).
Any idea?
Thanks in advance.
Edit:
What I mean by this: I want the admin to be able to pick a folder. I just want to retrieve the path, and use it somewhere else; not necessarily right afterward.
After retrieving the uploaded file, I currently use:
move_uploaded_file($_FILES["file"]["tmp_name"], "../../../img/" . $_FILES["file"]["name"]);
to store the files. I just wanted to allow to store the path in a variable through an input and use it afterwards in this case.
I'm not talking about browsing user's folders, but allowing the server to pick the location where files are downloaded, on the server itself, without writing the path, just by letting the admin selecting it by browsing files.
The flagged duplicated post does not answer or not totally answer what I'm looking for, since it's either selecting a folder - with every files in there - or not allowing to select a folder which is empty. Would be perfect to reproduce the functionality of those "select a directory" functions when you first install a software.
I hope I clarified enough, I'm really bad at explaining things.
[EDIT] I'm working on a web UI with the following attributes:
The web server runs locally on the user's machine
The location of the csv files in question are static, and never change
The UI uses javascript to communicate with a Java REST controller, which then handles the heavy lifting for the file reading/editing/writing
In the UI itself the user selects a csv file, then that file gets loaded into the UI for viewing, editing, etc. I wanted to pass the path to a REST controller, then have the receiving Java application read the file, etc. but it appears you can't get the path using input type file for security reasons. For my purposes though this would work just as well if I can limit the directory access since the files will always be local and always be located in the same place. Basically, the user can select csv files from one of several directories:
.../CSVType1/*.csv
.../CSVType2/*.csv
.../CSVType3/*.csv
So if the current type being edited is CSVType1 I'm trying to prevent the user from accessing the other directories in order to prevent them from trying to load the wrong type. If the path could be accessed I could do a quick check and throw up an alert if they're in the wrong directory, but limiting access would work fine too. Right now I've got it so that it only accepts csv files:
<input type="file" accept=".csv" ng-model="CsvFileInfo.selectedFilename" id="csvFile" style="display:none" />
But is there a way to say 'only accept csv files within this directory and its subdirectories'?
i want to display pdf files in my website but unfortunately it will automatically download by idm.
here's my code:
$
<div class="viewerthesispdf">
<div id="viewer" class="pdf-viewer" data-url="<?php the_field('upload_pdfACField'); ?>"></div>
data-url is used to embed a file in a web page. That makes sense for images. It doesn't make sense for a PDF (or Excel or Word or most other file types) because normally these types of files are in place of a page, not a section of a web page. There are generally two solutions, depending on whether the files need to be restricted:
Use an href tag to reference the file. Download File1 I usually include target="_blank" in order to force a new page so that if there is a problem with the download you don't "lose" the original page, but it isn't strictly necessary. This will simply give a link to the file - and you can use a button, Font Awesome, images, etc. to make it fancier - but in the end "a link to a file".
Create a form which returns only the PDF as a result. Again I usually include target="_blank". The advantage of a form is that (a) the file doesn't have to actually exist on disk - it can be created by a script on-the-fly (technically this can be done with a link too - but typically a link would be a file rather than a script) and (b) you can include any necessary parameters for security, user-specific customization, etc. as part of the form. The form can use a GET or a POST depending on your preference.
Use href to show your pdf file list like this Filename , it will not start downloading automatically, only when user click on it, it will start download.
I am trying to allow users to upload pictures to the server.
I am trying to create a similar system to any website that has an 'attach' file or 'upload image' feature. All I need is to get the full path of the file select by the file dialog.
I tried using this for the file dialog with no success:
<input type="file">
This method does not provide the full file path, due to security reasons. My question is how can I create a similar input dialog to websites like tinypic, photobucket, etc.. that can help users input the full file path of a given image, into an input field?
I am aware that this cannot be done using the method above for security reasons, however, I have seen this done before on various websites without any problems, I was wondering what I had to do to implement a similar file dialog that helps fill in the text, which is a full file path, of an input field?
It is not possible to get the file full path on local machine using browser and javascript.
However, as you would like to upload the file to the server, the easy possibility I see is to use html form with input type file. You will receive the file on your http server when the form is submitted.
Here is a very good url http://www.cs.tut.fi/~jkorpela/forms/file.html that explains the whole process nicely.
I'm a beginner! I need to read data inside txt files in a local folder offline. I know the folder path, but I don't know the name of every single file.
C:\mypath\first.txt
C:\mypath\second.txt
C:\mypath\third.txt
...
To read a sigle file now I use:
$.ajax({url:"C:\mypath\first.txt",
success:function(result){
//...code for storing the data in a variable...
}
});
How can i read multiple file at once without know their name? something like:
$.ajax({url:"C:\mypath\*.txt",
success:function(result){
//...code for storing the data in a variable...
}
});
Thank you for any help!
You can use a file picker control (ie, <input type="file" multiple />) in a supported browser and have the user select the set of files to iterate. User input is the only way to get the list of files - you can't just go mucking about in a user's file system over the internet. All you can learn about the user's system is what the user tells you (eg, through <input type="file" multiple />).
And even then, you won't be able to read the file with a simple Ajax request. Same origin policies apply to local files. It may work if you test it on your own machine, but as soon as it hits the web, it will fail.
The only way to look through a client file system without user interaction is by using a Scripting.FileSystemObject ActiveXControl on windows in a non-internet based HTML Application (.hta file). So, since you don't want to use ActiveXControls, user input is your only option.
Edit: If you are creating a FireFox add-on, you can access the file system. See the documentation at mozilla.org for details.