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.
Related
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?
I have a jquery library in my project but need to put it in linux /usr/share/js directory and not inside of my project directory.
Is there a way to do a linking in the index.html?
Including in the index.html:
<script src="/usr/share/js/jquery.min.js"></script>
doesn't help, as it looks into my working dir and I don't have a 'usr' dir
/usr/share is in the root directory and not in my working one. I don't use any php or the stuff, is there a simple way to solve this?
You need to back out of the file you are currently in by using the ../ command which goes back one directory. Depending on how many files deep the index.html file is in your project, you may need more then one like so:
<script src="../../../../usr/share/js/jquery.min.js"></script>
This will direct you 4 files out of where your index.html file is located, you may need more or less depending just do some searching through your directories and adjust accordingly.
You can create symlinks for files like this, to allow access to serve from not your document root.
The web server is also needs to be configured to follow symlinks when serving.
More info for Apache:
http://httpd.apache.org/docs/2.4/urlmapping.html
Maybe it's a stupid question but i am a newbie using node js, and I think that it can be used just with js files, I dont know, I installed node js on my windows and i started the web server but i dont know how to run the files, I have always worked with apache, I saw there is a folder called scrips in the node js installation folder
but i dont know how to run the files, I have always worked with apache.
In NodeJS, it's either you write the web server (it's like writing Apache itself), or use a framework that does it for you (it's like adding in something like Apache). Suggesting you check out Express. It's something almost close to CodeIgniter (writing points of entry).
Can i run a php file or a html file in a node js web server?
NodeJS is for JS. Your server files are all in JS. As for HTML, checkout Express (mentioned above), or if you just want to serve plain HTML (or static files), you may want to check out Connect Static
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.
I'm working on a js project that follows this directory structure:
/doc
/src
/test
/etc
This client-side js app can be configured by a server app (a whole separate application) via json. We define the structure, attributes, attributes description and allowed attribute values for that json data using some xml files. Those xml files are parsed by the server app so it can send a correct json object.
Should I create a new "dist" directory for that xmls as they are distributed to the server app team. Or should I put them in my doc directory as they in some way document the interface between the server and client apps. Or should I do something different? I'm asking for best practices.
Sounds like these files are a resource, so I would put them underneath a resource directory. Probably something like /src/resource or /resource.