how to upload a file from local machine to server?
Here' s an interesting question. I want to upload a text file from my local machine to a database system website in one click of a button for ease-of-use for my clients. What I want to avoid is having a standard upload control in a form on the site and having to do it manually. The database system on my local machine will keep a log file that I want to upload to the online version of the system in one simple click of a button.
What I am thinking is to copy the contents of the log file to an HTML hidden variable, then post that to a PHP program on the server that then do what it needs to do with it. This log file could potentially be 500K or up... so I am wondering if it is a good idea to put this much data into a hidden variable or text box control
So are you saying you want your web page to automatically read in the contents of the log file into a hidden form variable?
I think, for good reason, the security mechanisms built into the browser (and the OS itself?) would prevent such an action. Unless ... you used a Java Applet and explicitely granted it permission to your File System. That would actually work come to think of it ....
If this is just for yourself, that (applet) would be a viable solution. However, if this is for the general public, I think nobody would go for it.
In fact this log file is created from my PHP program, it is not system related at all and hence security is not an issue. I am just worried that HTML form variables have a maximum limit as to how much I can store in them, or the server has a limit as to how much it can receive.
Ahh. Yea there is a php setting that controls "post_max_size", but I believe the default is set to 2MB on most systems. So if your logfile is only 500K, that shouldn't pose a problem.
If you log file contains quotes or special characters in it, it could break the syntax on the HTML form field. You might want to consider base64 encoding the contents of the file. (see base64_encode() on PHP's website).