Accessing a file on the server's hard drive - javascript

I have a webpage that needs to read a status file on the webserver hosting the page. The file is on the hard drive of the webserver just not under inetpub/wwwroot/... I know how to access the file if it is in the same directory as the webpage but not if it is in a different directory.
Is there a way to do this?

You cannot reach the file that is "above" the wwwroot folder by design. The way to do this is to a) copy the file there, b) setup a symbolic link (if on linux) or c) preferably, move / setup another web root folder.
Alternatively, write a server script to dump the file contents.

Related

Is there any way to load js scripts in XAMPP with the same folder structure as in a regular server?

I have XAMPP and a separate cloud server. Inside XAMPP's htdocs there is a folder with a repository that I use to both develop, and push to the cloud server.
When using the same folder structure as the server ie. a script / js folder holding all the js files in the root of the folder (public_html/scripts) the server works fine.
The problem comes in development, where trying to access the scripts using src = "script/scriptname.js" gives me the error saying "Failed to load 404". Now I know it's just trying to search in localhost/scripts or htdocs/scripts rather than htdocs/projectname/scripts. I don't really want to have to move the script folder in and out all the time, as that's really tedious.
Is there any way to use a script folder without having to move it around in Xampp?

Which server directory to place webapp files for a node js application

So I feel like this is a simple question that has just been evading me so hopefully I can get some help here. I have developed a nodejs webapp, the directory structure can be seen in the screenshot below. Eventually, this app will implement a mongodb and house a hefty size of audio files.
I am using the inMotion Premier Support hosting plan (pretty basic) and when taking a look at the server through fileZilla I see there is a public_html directory.
Do I put the whole contents of my webapp (everything in the screenshot) in the public_html directory? I assumed that only the files that should be publicly accessible should go in there (only the contents of my apps public directory). If that's the case where would I place the files that would be considered server-side (everything on the same level as app.js).
Also my hosting service isn't dedicated or even virtual so I don't have access to the whole server just a certain number of directories.
Any help is appreciated
I am currently working on a webapp.
What you want is a VPS on inMotion, not a FTP server. The public_html directory in these web hosting services is where you usually put static html files. If you want to deploy node.js web apps, look at getting a server through VPS.

Install files to sdcard on Android/IOS with phonegap

I have some files that I need to copy to a folder once the user has installed my app. I was trying to find a way to transfer the files directly from the application root directory but no luck. I had also seen a suggestion about zipping the files and including the zipped file in my package, then extracting them to the folder. But did not know how to implement either methods.
Another alternative is to download and install the files when the app starts, but didnt want to rely on having to maintain the files on a server or that the user always has internet access since my app can be run offline.
How do I do this with a Phonegap/JQM/Javascript app?
Thanks,
Robert

Phonegap: download resources from external server and start from downloaded file

I am planning to create a responsive website using jquery/backbonejs.
my plan is to create a simple webapp to be used in phonegap (and deployed to android and iPhone via appstore/Google Play) which does only check what resources are on the server (via JSON) and download them all. after downloading them, i would like to jump to the folder having all the downloaded files and start from there.
Since iam not allowed to download files directly into my phonegap app folder, i guess i need to download the files into some kind of document folder used by the app. But the question is, is it possible to redirect from my phonegaps index.html to that other index.html in my documents folder having all the downloaded files. would it work linking to jquery.js and images being in that folder located in js/ or img/ ?
That way i could keep my app up2date, but it loads only if there is something missing or updated on the server.

forwarding to a html file whose directory name changes

I have folder structure like the following
-> Parent folder
---> version_HTML (folder)
-----> index.html (file)
I would like to use an HTML file with javascript at the version_HTML level which will look for the file index.html in the subfolder and open it, as the folder name will keep varying.
The HTML file will be run from the local directory, and will not be hosted on the server or WWW.
I am open to alternative solutions too.
Any help is appreciated.
As I understand you want to create a file on the server from a web page, it's not possible only with Javascript, and the way to do it is non trivial for a non developer.
The parent's name is not so much important since you can ask "create a file on my parent folder" but it has to be done by a server-side language, you can look at PHP, python or nodejs.
Also you'll need to send a AJAX request from Javascript to the server when you want the server to create this file. I insist, is not easy for a non-developer.

Categories