Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading files only on the server side + "readonly"

Status
Not open for further replies.

kitus

Programmer
Sep 22, 2005
10
0
0
DE
Hello everybody!

I've been working on a PHP script with access to a Mysql database and I need your advice guys with these topics...

This script is requested to load a template file out of a pool of templates placed on the server side; therefore I used the syntax

echo "<TR><TD>Template file </TD><TD><input name=\"template_file\" type=\"file\" /><br /></TD>";

that simply opens a file dialog and lets the user upload a file.

I'm that this feature is up to the browser and that's why the upload dialog "points" to the user (local) machine and not to the server. Since coping these templates to each user is kind of a nonsense, the question is, is there anyway I can open only a file window dialog "pointing" where these template files are stored on the server and of course limiting as well the read procedure to that folder only?

Besides, I would like to provide the user with the possibility to modify some contents of a form. With my mozilla browser, everything works fine but from konkeror or even from internet explorer the files that were designed to be "readonly" can be modified!! This, of course, messes up the flow of my script making it crash!!! Any suggestion??

I hope that I made myself clear enough It's kind of hard to explain problems like these when you're not a native ;)

thank you, any help will be very welcome!!!

kitus
 
It is, I suppose, possible to arrange it so that a user can point an HTML input of type "file" to a web server. But this would likely be frought with security issues on the server-side, browser- and operating system-dependent, and clunky.

Why not just store the templates on the server and give the user a set of radiobuttons on which to store the templates? If the templates must be user-provided, then give your site the ability for a user to upload a template, then have that template appear in the radiobutton set.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Rather than trying to use the file input, why not change to use a select input. You can loop through the directory of templates using php, and collecting the names of all the files. As you loop through you would make up the options:
Code:
$_html .= "\n".'<option value="'.$_value.'">'.$_display.'</option>';
Then present thm on the page wrapped in the select input:
Code:
<select name="someName" onchange="someFunc()">
<?=$_html?>
</select>
I'm sure you get the idea. This will allow your user to select a template on the server.

At least that will give you an idea of how to progress.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Thanks for your suggestions sleipnir214 and Jeff!!

at the end i managed it with these radio buttons and seems to work quite fine... thank you guys.

What about my second question? is there anything wrong with these bloody browsers? do I need to make a big IF treating in a different manner konkeror and internet explorer? How the he** do I make the information in the forms as readonly... Imagine my face when I tested my script in my boss office running Iexplorer?? damn it!!! Am I missing something??

thanks a lot in advance!!!

/kitus
 
I have tested the following on Windows using IE(5.01, 5.5, 6), Opera(6.06, 7.54, 8.5), Netscape (7.0, 7.2, 8.03), Moz 1,7 and Firefox 1.07. They all honour the readonly status:
Code:
<html><body>
<form>
	<textarea readonly>Lorem ipsum dolor do consequat.</textarea>
	<input type="text" readonly value="consectetuer adipiscing"/>
</form>
</body></html>
I was unable to get any success setting radio and checkbox inputs to be read only - it would probably be best to create hidden inputs to hold their true value, and then use the disabled flag on the actual radios and checkboxes to prevent them being altered in the GUI.

Maybe it's worth posting some samples from your code - starting a new thread in the HTML forum with this problem. Assuming you don't find something suitable before then.

Cheers,
Jeff

[tt]Jeff's Page [/tt][tt]@[/tt][tt] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top