I am trying to make a user-friendly Python program where the user enters the input in an HTML file instead of calling the functions from the console. One of the inputs is the directory of the dataset. because it is friendlier to show the user where he or she is choosing as the dataset path, I am using <input type="file">. however, I understand that for security reasons browsers won't return the full path of a folder but I was wondering if there is a way to get the full path when the server and the client are the same which is as friendly as <input> option.
Related
In my app, users can fill a form (all kinds of inputs, including file inputs). At any point and after posting that form to backend, they can edit the form. In that case, the text/selects/numbers... are set to the value entered by the user previously.
What would the best practice be for file inputs ? I know I can't "preload" them for security reasons.
These files are stored on the backend. I need to find a way to figure out :
If the user hasn't changed the file
If the user has changed the file
If the user wants to remove the existing file (if possible ?)
In one of my applications users have an option to upload the document. In that process I upload the document on the server in specific folder and save the path in database column. After process successfully saved the file path column looks like this:
C:\wwwroot\myapp\documents\Document 03072017.pdf
This path should give me direct access to this file. However, now I have administrator portal where they should be able to download the file. Each record in database is saved with unique key. The document above for example has key column with the value 09824982. When I show records on the screen for administrators, I would only show the icon for the document type. For example if document is pdf they will see pdf icon. If document does not exist for that record then it will be blank. My question is what is the best way to process the download int his case? Ideally I do not want to show the document path to the user. If they use dev tools I do not want to display that document root. Is there approach to download the file based on the key that I showed above? For example send ajax request with that key and then look up in the database record pull the path and download the document? I use JavaScript/JQuery with ColdFusion 10 and Oracle database. In the past I used ColdFusion to download/deliver files to the browser. This time I have single page app and CF is only used on the back end. If anyone can provide some example or suggestion please let me know.
I was looking around trying to find a solution but was unable one. What I want is the take whatever the user enters into text fields and save those into an xml file. Then I want to prompt the user to save that file.
What I mean is to get the info from many different input fields through document.getElementById('id').value and put that into the file.
For example:<lessonname>document.getElementById('lessonname').value</lessonname>\n
I want to access url of file which user select through pop up file directory navigation window. My browse button tag is:
<input type="file" id="loadFile"/>
On the back end, i can access the file url in javascript, but not sure how to do it in PHP.
You have to have the correct enctype for the form.
Otherwise, you utilize the $_FILES super global.
This is covered extensively in the PHP Manual regarding uploads.
The original filename is available in $_FILES['load file']['name']
Since it seems that you actually want a way to have the user provide a url to a file, the way to handle that is to simply implement a text input and accept the url there, and process the url on the server, using an HTTP client that fetches and stores the file on the user's behalf.
For years people have been using the curl extension, which is fast and highly functional. There are also a number of client libraries written in php like Guzzle.
I wonder if it's possible to choose a file and then save the location to the file to the database, for example C:\folder\another-folder\file.txt through HTML or JavaScript?
Thanks in advance.
No. You can't do that in browser because of security restrictions. You can get its name (`file.txt'). The only thing you can do - is to give a user an input to select and upload file. After it is on your server - you can do with it whatever you want.
Javascript and HTML are both evaluated on the client (browser), so without any server-side scripting this is not possible.
Not completely sure since I have never actually done something like this in the past -- most likely it is not possible to get the actual location of the file in the native system unless the user inputs it directly, but perhaps you can extract it from a file upload?
http://www.w3schools.com/jsref/dom_obj_fileupload.asp