SoWizardly
SoWizardly

Reputation: 407

Prefilled html file input?

So I have a very simple file upload form, code below...

 <form enctype="multipart/form-data" action="$theaction" method="POST">
 <input name="source" type="file">
 <input name="message" type="text" value="">
 <input type="submit" value="Upload"/>
 </form>

I was wondering if I can set with php the source of the file upload? Something like..

 <?php $file = "http://mywebsite.com/path/to/img.jpg"; ?>
 <input name="source" type="file" src="<?php echo $file; ?>">

I've googled it but I can't come up with anything. I feel like I'm just not using the proper vocabulary, but any help would be greatly appreciated!

Upvotes: 2

Views: 2993

Answers (1)

Rakesh Sankar
Rakesh Sankar

Reputation: 9415

I concur @IMSoP statement.

Instead of populating the input tag value, I would rather create an element (div) to display the thumbnail version of the image that was uploaded by the user that way it makes it clear to the user that a file exist and also I would give them the option to edit for uploading a new file & delete for deleting the file.

Upvotes: 5

Related Questions