March 23rd, 2012, 10:31 AM
-
Input name ="File" , set the initial value
I'm really not sure if this a PHP or HTML question.?.
I'm building an edit photo page for my website and would like to change the photo with the browse for file button. When I echo the photo file name with a text field, i get a initial value of the current photo. When I change input name from "text" to "file" I get the "no file selected". If the user doesn't select a photo or the same photo it deletes the database photo file name. I am currently echo-ing out the original name in a row above the browse for file row. Here is what I have tried so far:
echo out old photo name:
PHP Code:
<tr valign="baseline">
<td nowrap="nowrap" align="right">Org. Image File Name:</td>
<td><?php echo $row_rsPhotos['fullSize']; ?></td>
</tr>
Browse for file:
PHP Code:
<tr valign="baseline">
<td nowrap="nowrap" align="right">New Image File Name:</td>
<td><input type="file" name="fullSize" value="<?php echo htmlentities($row_rsPhotos['fullSize'], ENT_COMPAT, 'UTF-8'); ?>" size="32" /></td>
</tr>
Is there a way to add a default value of the original photo name ("fullSize") to the browse for file button?
-Jake
March 23rd, 2012, 11:32 AM
-
You cannot set the value of a input=file.
In the PHP, don't delete the photo if one was not uploaded. If you want to allow deleting then give a separate "[o] Delete this photo" option (eg, radio or button) and check for that separately.
March 23rd, 2012, 08:04 PM
-
Thanks requinix.
It sounds like I need some javascript to do that? I have seen that in forms where one selection opens new field to fill out. Thanks for the help.
-Jake
March 23rd, 2012, 08:57 PM
-
You don't need JavaScript for it. Look at the avatar page: it's just two radio buttons.
April 20th, 2012, 11:17 PM
-
Initial value
Initial value could be given by the item properties. In dreamweaver you can give it easily.
April 21st, 2012, 12:45 AM
-
Initial value could be given by the item properties. In dreamweaver you can give it easily.
No, that is not correct. You cannot set an initial value for an input=file field.
PHP FAQ
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
April 21st, 2012, 02:04 PM
-
Thanks E-Oreo, I'm still working on the details of my photo management. I'm going to post over in the mySql section about my new problem.
-Jake