#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    29
    Rep Power
    0

    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
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,238
    Rep Power
    9400
    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    29
    Rep Power
    0
    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
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,238
    Rep Power
    9400
    You don't need JavaScript for it. Look at the avatar page: it's just two radio buttons.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    18
    Rep Power
    0

    Initial value


    Initial value could be given by the item properties. In dreamweaver you can give it easily.
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    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
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2012
    Posts
    29
    Rep Power
    0
    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

IMN logo majestic logo threadwatch logo seochat tools logo