The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Sticky value in type=file input tag
tonym
post May 31 2010, 02:46 AM
Post #1





Group: Members
Posts: 2
Joined: 6-December 07
Member No.: 4,492



I have a php script with an <input type='file' class='browse'.......> tag in the form and I would like to make this value sticky. I get the file name ok when I submit the form; how do I put the retrieved value back in the box when the form reloads? Using <input type='file' value='filename' class='browse' .....> doesn't appear to work.
Thanks
Tony
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post May 31 2010, 03:12 AM
Post #2


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



AFAIK, you can't. It's a security issue.

Some of the systems I use will store the uploaded file on the server, providing a link to it on the updated form, and requiring a file upload only if the user wants to change the file.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
ExpertsGuide
post Sep 14 2010, 05:57 AM
Post #3


Newbie
*

Group: Members
Posts: 12
Joined: 14-September 10
Member No.: 12,725



If you are not bothered about the security then you can do this,

CODE

//get the value of the input field (<input type="file" id="file">) using
var filename = document.getElementById('file').value;
//put this in some hidden input field (<input type="hidden" name="ctfilename" id="ctfilename">) using
document.getElementById('ctfilename').value = filename;

This will be captured at server and then you can do whatever you want.

But bear in mind this is security issue.

This post has been edited by ExpertsGuide: Sep 14 2010, 05:58 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 8th May 2024 - 04:40 PM