...

View Full Version : Resolved populate input type=file field with existing data



dnnhater
08-24-2011, 10:05 PM
so I have a form that be used to update existing carriers and one of the fields is to allow to upload an image associated with that carrier - is there a way to populate that input field with the existing file name? this is maybe only the 2nd time ever that I've needed a file upload thingy so I'm not even sure how to google for the answer on my own


<?php
$page->contentSet('
<form action="" method="post" enctype="multipart/form-data">
<p>
Carrier ID: '.$getCarrier['viewCarrierRow']['id'].'<br />
<label for="name">Name<span class="required">*</span>: </label>
<input type="text" name="name" id="name" size="30" value="'.$getCarrier['viewCarrierRow']['name'].'" />
</p>
<p>
<label for="address1">Address 1<span class="required">*</span>: </label>
<input type="text" name="address1" id="address1" size="30" value="'.$getCarrier['viewCarrierRow']['address1'].'" />
</p>
<p>
<label for="address2">Address 2: </label>
<input type="text" name="address2" id="address2" size="30" value="'.$getCarrier['viewCarrierRow']['address2'].'" />
</p>
<p>
<label for="city">City<span class="required">*</span>: </label>
<input type="text" name="city" id="city" size="30" value="'.$getCarrier['viewCarrierRow']['city'].'" />
</p>
<p>
<label for="state">State<span class="required">*</span>: </label>
<input type="text" name="state" id="state" size="5" value="'.$getCarrier['viewCarrierRow']['state'].'" />
</p>
<p>
<label for="zip">Zip<span class="required">*</span>: </label>
<input type="text" name="zip" id="zip" size="10" value="'.$getCarrier['viewCarrierRow']['zip'].'" />
</p>
<p>
<label for="phone">Phone<span class="required">*</span>: </label>
<input type="text" name="phone" id="phone" size="30" value="'.$getCarrier['viewCarrierRow']['phone'].'" />
</p>
<p>
<label for="fax">Fax: </label>
<input type="text" name="fax" id="fax" size="30" value="'.$getCarrier['viewCarrierRow']['fax'].'" />
</p>
<p>
<label for="logo">Logo: </label>
<input type="file" name="logo" id="logo" size="30" value="'.$getCarrier['viewCarrierRow']['logo'].'" />
</p>
<p>
<input type="hidden" name="editCarrier" id="editCarrier" value="1" />
<input type="submit" name="editCarrierSubmit" id="editCarrierSubmit" value="Update Carrier Info" />
</p>
</form>
');
?>

Fou-Lu
08-24-2011, 10:33 PM
Standards dictate that you may provide a filename as a default value. This would be a full path to the file on the client's system.
Best I know, most (all?) browsers will completely ignore the value attribute of the input type file for security reasons. So to answer your question, no you cannot reliably set a default file.

dnnhater
08-25-2011, 02:26 PM
what you say makes perfect sense - at least now I know why I couldn't find anything on how to do it lol

thanks so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum