Jump to content
Stef's Coding Community

Using Php To Set Default Value In File Form Field

Recommended Posts

I'm just trying to get a default value to show up in a form field (type=file) using the example below. Anyone know what I'm missing? I know the variable $imagefile is being populated correctly because I've tested it. Is it just something I'm missing in the html input tag at the bottom?




// above in the php script:


if (isset($_GET['id'])) {

$targetID = $_GET['id'];

$sql = mysql_query("SELECT * FROM products WHERE id='$targetID' LIMIT 1");


while($row = mysql_fetch_array($sql)){

$imagefile = 'images_folder/' . $targetID . '.jpg';





<!-- below in an html form: -->


<input type="file" name="fileField" id="fileField" value="<?php echo $imagefile; ?>"/>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...