GuangXiN wrote:
> Evertjan. wrote:
>> GuangXiN wrote on 11 jun 2008 in comp.lang.javascript:
>>>> As a security measure, you cannot manipulate the input file element
>>>> of html upload forms. Otherwise it would be too easy to secretly
>>>> upload another file than the one shown and so compromize the user's
>>>> private parts.
>>>
>>> OK, let me explain my words.
>>> I wrote a file upload component, but I cannot modify its sytle to what
>>> I want. So I added a textbox and a button with style, and then I make
>>> the file upload component hidden, I want to use script to simulate the
>>> file upload's "Browse" click. I am sure that file select dialog popup
>>> when I click the button. I select a image file, the path and filename
>>> did display in the textbox.
>> As I said, security could be compromized by that.
>> The browser does not contemplate your possible good intentions.
> Is there any other way to implement what I need? I just need a file
> upload component with customs style in css file.
This is rather a question for comp.infosystems.
www.authoring.stylesheets.
But I am pretty sure you will have to live with the fact that a custom style
cannot be applied to this control in all user agents, and I can't think of a
*viable* alternative.
> PHP has an $_FILES arra. When submit with a file, it will be not null.
> I tried to make the file upload component appear and I click the
> following button (NOT the Browse button in fileupload component). I can
> choose a file and the file upload component show its path correctly.
> I click submit and PHP shows that $_FILES is still null.
Of course. By disabling the file input control you have only caused only
the encoded file path to be submitted per `photoUrl'. A file input control
in a form causes the encoded content of the selected file to be submitted
instead. And if it was possible to set the value of that control with
scripting, any Web site you visit could upload any file from your computed
without your knowing it; you do not want that to happen. (Using
display:none as suggested will not change that.)
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee