I'm creating UI for backup and restore database in my J2EE app. I need to allow user to select a directory in his PC hard drive to save database backup.
I can select sql file to carry out restoration by this. <input type="file" accept=".sql">.
But i'm unable to find a way to select directory to save database backup file. I have google about this and found that there is no any way to select directories with jsp/html file.
Is there any way to achieve this ?
For security reasons browser will not allow you to select a folder on the users local drive to store files in.
What you can do is set the Content-Disposition header at the moment the file is sent to the client (browser). In that case the browser will show as 'Save as' dialog. With this the user can select the folder to store the files in.
See this page on how to set the content disposition header.
res.setHeader("Content-Disposition", "attachment; filename=\"" + filename +"\"");
res.setContentType("application/octet-stream");
Related
we need to develop an application similar to the below
On the web page user is asked to select the parameters which are present in a Map<String,Boolean>. Once the user selects his choice of parameters then this Map is saved in a .DAT file. Right now I am saving it in C:/Users/Application. But I want the user to choose which directory he wants to save. I was tempted to use <input type="file".....> but it needs a file in the directory.
Is there any way that the user can specify his own directory where this .DAT file is saved.
Something similar to SaveAs..
A webpage cannot choose where the user will download a file that is returned. For some file types, the browser might even show the file instead of downloading it (e.g. PDF file).
I am wondering if I can have a webpage where I can tell it to grab my file and put it in a directory, such as: "http://example.ex/folder". Meaning the file I provided is put into the "folder" folder.
Overall process:
Button says: "Import file"
I select a file, and my file is "text.txt"
It takes my file "text.txt" and adds it to the local system/directory of the website.
You can do this using JQuery File Upload and then adding a backend service that captures the file and saves it.
For example, here is a repository that has a basic Python (Flask) server integrated with JQuery File Upload that will take an uploaded file and place it on the server:
https://github.com/ngoduykhanh/flask-file-uploader
I'd put the rest of the code here, but it is a lot - and requires HTML, JavaScript and a back-end language (like Python).
Here is the documentation on JQuery File Upload: https://github.com/blueimp/jQuery-File-Upload
As a word of caution, DO NOT TRUST ANYTHING UPLOADED TO YOUR SERVER. Meaning, do not put it out on the open internet without some sort of authentication or checks in place to make sure only files you intend are uploaded. Otherwise, people will find it and upload scripts turning your device into a Bitcoin miner, spam relay, or bot host.
Instead of doing it this way, why not use SFTP to upload it to your server to host? At least that way you can lock down access.
I want users on my site to be able to upload large files (say up to 1GB), through html form. What I have so far, which works:
<h1>Upload new File:</h1>
<form method=post enctype=multipart/form-data>
<input type=file name=file>
<input type=submit value=Upload>
</form>
Will this work for large files ? Or should I use another way (considering that I'm a beginner in webdev) ?
I can't find references of a limitation on file size in html5 documentation, and only found ways to limit file size on SO (e.g. Limit the size of an file upload (html input)).
No, there is no size upload limit in Html input type "file"...
Following are the way if you want to check file uploaded size.
if (typeof FileReader !== "undefined") {
var Filesize = document.getElementById('fileId').files[0].size;}
There are several configuration parameters that can affect the file upload. These configuration parameters have to be setup right for the file uploads to work fine.
=> The folder in which the files are saved should be writable by the script. This is obvious but might be overlooked. The folder must be writable by the script means the web server user (usually www-data ) should have write access to the folder. So setup the folder permissions right. If you have shell access, the folder permissions can be updated using the 'chmod' command easily. If you don't have shell access, or if you have a shared hosting account, updating the folder permissions can be a little tricky. See if your hosting control panel has this feature.
=> The websever configuration The web server would have a configuration setting that (1) allows/disallows file uploads (2) sets a limit on the size of the file upload. Here are the typical settings you have to check (for PHP)
memory_limit
upload_max_filesize
post_max_size
I need to load a large number of pictures (around 30) in a sequence as a short movie, each .png has the size 960X540.
I don't want the loader depend on the name of each picture as I will make changes frequently.
Is there any suggestions?
Are you trying to load images from a local file system, or a remote web server?
If you want to load images from a local file system folder, you can use AIR's File/getDirectoryListing().
If you want to load images from a remote server, and you do not want to rely on a pre-defined file naming pattern, the server will need to be able to provide directory information, for example a PHP script that reads the directory contents and outputs XML or JSON. There's no general way for a client to probe a web server for files in a directory. Some web servers do have a default web directory listing script that shows when there is no "default" file in a folder (index.html, etc), but that probably won't be quite good enough for what you're trying to do.
As a final note, if you don't mind manually updating a file on the server that lists all the files as XML or JSON, you could create a simple AIR app to process a local file directory and generate the necessary XML or JSON and upload that to your server.
File input allows user to access a local file from browser. Is it possible to load a local file given by file input, modify it and save it back to same local file? I know that HTML5 allows creating writeable filesystem, but basically it seems to be abstract directory.
For security reasons, I don't think the browser can overwrite the local file. Using the File-System API you could only copy the contents of the local file to the sandboxed File-System API directory(found under various obfuscated file names). All manipulation/saving would be done in AppData.
Perhaps displaying the modified image on the screen, right click, save-as to the given file location would also be suitable? (other than that I think you have to upload the image to a server and download it back again)