I'm trying to update some text on a html page via jQuery ajax presently. This page's script calls an ajax request to a file in subfolder via jquery and displays that text.
I need to be able to update this file with text from a different html page.
I tried php, and found I didn't have file permissions to probably the ftp account or the webserver settings. Since php is the most popular method for file writing on a webserver, I haven't tried any other method.
I could try MYSQL + PHP for this, although I don't intend to put the root password in a text/php file.
I tried using Google Apps Spreadsheet with JSON output, and later found that JSON output was deactivated by Google (I guess).
Therefore, I was hoping to find a convenient way to get textual data from some source, and be able to update the textual data without any restrictions.
On most webservers, you will find at least one directory which is writable for PHP scripts. Else, you can place a file anywhere on the server and change the owner and write permissions, so that your PHP scripts will be able to write into that file. Please contact your webserver admin for details.
MySQL passwords in PHP files are no issue, as long as you put your PHP file outside of the directory that servers as root directory for your website. E.g. if your root is set to /var/www/user1/website1/, you can put a script inside /var/www/user1/, the PHP script shall be allowed to read that. This is the usual approach.
Related
I want to make a code using only JavaScript or/and jQuery to access a static directory and retrieve the names of some icons i saved there (SVG icons) and display the names to the user. i couldn't do that with the file api and i have no idea where to start.
I'm going to assume from your mention of jQuery and the File API that you're trying to do this within a browser.
You can't. It just isn't allowed, there is no mechanism to provide it.
If you're in control of the machine where you want this information to be accessed, you can run a server process on it that can do that; code in the browser can then make a request to the server code to request the information. But there's no browser-only way to do it.
Environment:
html5
JavaScript
Angularjs
node.js
express.js
Couchbase
Question:
I understand the concerns and security measures implemented within the web environment to prevent the display of directory paths to the world. However, I have an issue that requires knowing the full directory path to a selected file.
I am building a web page for an internal website. The web page needs to allow the user to select a tab delimited file. This tab delimited file will exist on a network server, which is a policy instituted by the company and mandated by external auditors. This file may exist for various clients, with data specific to the client. With that said, the files will reside within different folder structures on the server(s). The user wants to pick the appropriate file and have the data uploaded to the database. Based on the size of the file (up to 10’s of millions of rows), the user does not want to wait for the web page to process immediately. Therefore, the solution is to create a task. The task will contain all the parameters necessary to manipulate the data prior to uploading the data to the database. I understand the simple solution is to upload the file to a common directory but that is not practical. As the user could set up several tasks that will upload the same tab delimited file to the database using different parameters.
I would like to have my task creation process contain the file name with the directory structure. When the background process executes the task, it can extract the data from the original location. Additionally, if I have multiple tasks extracting the same data, I not concerned I may have multiple copies of the data present.
I will appreciate any help with code snippets, website, etc. that may suggest methods to resolving this issue. Please not, that at the current moment, PHP is not an option. A management decision prevents the use of PHP.
TIA
Anthony
It is not exactly possible, so I see two solutions. One is to try and get the path to the temporary location of the file, rather than the actual permanent location.
Suppose your has an id of fileInput and you're using jQuery:
$('#fileInput').change( function(event) {
var tmppath = URL.createObjectURL(event.target.files[0]);
console.log("Temporary Path(Copy it and try pasting it in browser address bar):"
console.log(tmppath);
});
Otherwise I would just make a separate input for path, and show a brief instruction to users on how to copy-paste the URL from their Windows Explorer window.
I have a website that allows users to select a date range from a data set. At least, that's the goal.
What I would like to have happen: the user selects a date range, presses the submit button, and a script generates a JSON file which MATLAB reads to generate the graphs.
Any thoughts on resources to help accomplish this?
You'll need the script that fires off to be server side. JavaScript is client side and can not, in any way, access, modify, or otherwise create files on the client. You'll have to use a language like PHP to create the file.
Example using PHP:
Once the file is created, force a request on the client side to fire asking for the file. Set the PHP header to Content-Disposition: attachment; filename="< Place file name here>".
This will prompt the browser to launch a download prompt allowing the user to download the file.
Hope this helps.
You can use Downloadify, a small Flash component with a Javascript interface that allows you to create files on the client that a user can download. That's what I used in a similar situation.
You could also try and use Data URI but they are a quite limited and browser specific so some issues may arise.
These may be alternative solutions to the previous answer that suggested using server side code to generate the file.
I have researched this but found luck and my question really is a hope and I'm doubting this is possible.
Can you route URLs to a specific PHP file using JavaScript? Like you would with rewrites in .htaccess. It would be a lot easier for several reasons for me to just link a fake URL to a PHP file with JavaScript.
The scenario is that I am creating a user profiles with PHP, a database and jQuery. Since I am using a history API script I can easily provide a profile for users without editing the .htaccess file IF a user navigates to a profile with a link. To do this I would preventDefault on the link click so you don't get a 404, get the href value, use AJAX to get JSON data from a PHP file and then AJAX in the template with info loaded in.
The problem is when a user directly enters the URL for example www.example.com/joebloggs, this would just cause a 404 since that file does not exist. I would like to intercept the page load with jQuery and instead load up the PHP template and ajax in info with JSON.
If not possible I will use .htaccess it would just be easier to do it with JavaScript
I need to fetch complete the path from file select element of HTML using JavaScript. I have returned a JavaScript function, but it fetches only file name not the complete path.
How can I get the complete file path?
You can't. It's due to security. The browser only provides the content and the filename.
Providing the path could allow an attacker to learn things about the files on your hard drive that they want kept private. Do you really want to let the web server know that the kitty.png you are uploading for your avatar was actually in c:/pr0n/?
No, I didn't think so.