How can HTML page be populated with values from ini file - html

On a webserver when I get a request to serve page index.html. How can I send certain values from an an ini file.
For example, index.html on server contains
<input type="number" name="userChunkSize" value="1024">
Here, I don't want to send the value statically harcoded in index.html, but instead this value should be read from an ini file having the below lines, located at the same place in server as index.html
[index.html]
value=2048
After reading the ini file the final index.html returned should be
<input type="number" name="userChunkSize" value="2048">
Any suggestions on how a better architecture can be done would also be greatly appreciated

It is highly unusual to use an .ini file for such a purpose. Values that need to be generated dynamically should be created using a server side language such as php, asp, python, etc... Then your 2048 could be loaded from a server side .ini file (not a great idea), or preferably from a database.

Related

Is it possible send a specified file (input type=file)?

I need to upload a file repeatedly by browser (automatic) and refresh time ask me for confirm.
How can i to POST form with a specified file?
Sorry my english
It would be nice if you make available what you already tried, then we know where you are getting stuck.
Basically if you need to upload a file to a remote server you will need a dynamic language like PHP, Python, etc.
You can't send files to a remote server using plain HTML.
For security reasons HTML itself won't let you send files to a remote webserver via <form> automatically.
For that feature you would have to have your webserver handle the form via a special file like for example <form action="exampleFormHandler.php" method="post">.
Placed at your webserver, this form-handling file would have to provide the sending of that very file then.

how to embed pdf file in html with security?

I am using below code to display pdf file in HTML
<object data="data/file.pdf" type="application/pdf" width="300" height="200">
test.pdf
</object>
But In above code we have to specify path name and folder name so it is not so secure. Crawler can find this path, so using some algorithms(robot) it is very easy to download other file those are stored in that folder.
How to secure this, is there any option to prevent this from robots?.
You may do the following:
Password protect the page (with the server-side code).
Generate unique links like (/getpdf/some_random_string_or_md5_hash_of_random_string.pdf) for every PDF file (using server-side code) that will a) check for the current time and the validity of the random name generated (if it has expired or not) then b) will redirect to the source files (not really hiding the source because of the redirection) to be displayed or stream the PDF file content (this is more secure though could seriously add the load to the server).
Finally add robots.txt to the folder and hope that crawlers will follow restrictions it sets.
If the other files in the directory are not to be downloaded, ever, they shouldn't be in a directory that is available to the http server. You can use directory permissions in your http server (eg., config directives and .htaccess in Apache) to control access to directories. Only configure access for directories you need to expose to the web, and only store files in them that you want the web to access.
If you want to avoid including a path in the HTML, you will need to write some dynamic code (eg, php, asp, or any number of server-side options). Your code on the server would need to handle the request for the file and return the file's content manually.

save html page from the server by URL with no changes - get the exact copy, the clone

Let's say I have a URL http://example.com/path/to/document.html
That's the html document, the file, that has no external css or js.
If I open it in Google Chrome and save it with Ctrl+S locally, the content is changed. The content of that html file starts with <!-- saved from url= which is not I want at all. I need to get the exact html document, even spaces count.
The second option is to copy it with Ctrl+U (View Source), Select All and paste it into new document, save it and rename it. This is better, however spaces, tabs and end of file will be different depending on what operation system I'm using.
I need the exact copy of that html file - byte to byte.
How to make it?
This is a practical question as I need slightly modify that document.
I'm sorry there is no any source code in my question, but this question is about web developing.
Any ideas?
Thank you.
P.S. Of course that document could be generated by php or whatever, the part of the code can be even extracted from the db, but not in my case. I know that's a plain file.
I'd delete the comment after saving from Chrome, use wget in a linux environment, or open the page as an InputStream in Java. Do all three, run a diff, and if two arrived identical assume that's the file on the server.
Why do you need a byte-for-byte copy of the file on the server anyway, and why can't you ftp the file? There is always the chance that the server will serve different html files depending on your user-agent, but there are other tools which may be better than Chrome for getting your copy and many can spoof a user-agent as well.

How to upload file by HTML only

<form action="upload.html" method="post" enctype="multipart/form-data">
<input type="file" />
<input type="submit" value="Upload" />
</form>
I saved this file as main.html
I made a dir called 'images' with chmod 777
what should be in the file called 'upload.html' ??
I don't want to use any php or asp files
just html files, so how can I do it by html files only ?
Client Side (Browser) => Web Server => Script => Server Manipulation
You CANNOT just use HTML files to upload to the server.
Web servers do serve static content (think 'GET') however
when it comes todynamic webpages or the ability for the client (browser)
to POST/PATCH content on the server you would need some sort
of script for that!
Choose perl, php, ruby, python, javascript, or whatever makes
you smile, and put that behind your webserver, with the appropriate
image uploading logic and you're good to upload pictures directly
to your server then :)
It's simple. You can't.
Call, main.php and have that contain code shown here to upload files to your server. It is fairly simple to do.
Your still going to need to use PHP/ASP somewhere. It's easier to utilize a single PHP file, but if you wanted your end users just to see an .html file instead, you could have it post to a php script file (but it must be a .php extension for the server to execute it).
As mentioned earlier, have a look at the W3 Schools post on PHP file uploading.
The simplest answer is no , you cant do it with the help of html . You need to use php or any server side language to handle file upload .
See this link : W3schools php file upload
Or you can use any other server side languages like asp , python , jsp etc...
An another possiblility is you can use javascript (client side) . Use javascript with ajax ..
See this link Click here

HTML 5 - load text from text files

I am facing problem in HTML 5. I need to statically load data into web page from local saved files. Up to now, I have been only able to load data via < input type="file" id="fileinput" / > but I want to load data from static location, which never changes. How to do that? And is there any way how to determine, whether some local file was changed from previous version?
Thanks
no, this isn't possible if by 'local', you mean a file at /home/waypoint/somefile.txt. You can make a 'link' with the filesystem api (if you selected it in an input field, for instance), which is valid to do computations with it (to read it, write to it, display it in img,etc). But it is deleted/unvalid, as soon as the window closes. If you could just magically "read" any local file via javascript which resides on the file system, who would stop google to read out your /etc/passwd file?
if your local computer is also your server and therefor your server-side code has access to the local file /home/waypoint/somefile.txt, your app can get it via ajax. Checking if the file exists, would be done the same way.