dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2003
    Location
    Hyderabad,India
    Posts
    486

    how to set input type file field value

    Hi all..

    i am not able to set the default value for <input type="file"> by giving the value.

    is there any way to achieve the purpose?



    Code:
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD>
    <script language="javascript">
    function callme()
    {
    document.form1.t.value="textdsfdsfdsfdsf";
    document.form1.file.value="c:\php.exe";
    }
    
    </script>
    <BODY onload="javascript:callme()">
    <form action="" name="form1">
    <input type="text" value="" name="t">
    <input type="file" name="file" value="c:\abc.jp">
    <input type=submit onclick="javascript:callme()">
    </BODY>
    </HTML>
    Thanks n Regards
    Harinath Reddy
    Learn Hello World Program
    A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible. There are no prima donnas in engineering. - Freeman Dyson

  2. #2
    Join Date
    Apr 2003
    Location
    Hyderabad,India
    Posts
    486

    is this true?

    does the browsers ignore the value?

    ref:http://www.htmlhelp.org/reference/ht...rms/input.html

    The file input type creates a field through which users can upload files from their local computer or network. The VALUE attribute specifies the name of the initial file, but it is typically ignored by browsers as a security precaution. The ACCEPT attribute gives a comma-separated list of media types accepted, allowing the browser to filter out inappropriate files. Current browsers generally ignore the ACCEPT attribute.
    Thanks n Regards
    Harinath Reddy
    Learn Hello World Program
    A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible. There are no prima donnas in engineering. - Freeman Dyson

  3. #3
    Join Date
    May 2003
    Location
    Denmark
    Posts
    1,315
    Yes, if the browser did not ignore the value, you would be able to upload any file from the users system, to your server, just by getting them to visit your page. The user would not even need to click submit on your form, your page could do that via a javascript.

    This would obviously be a major security hole.
    Last edited by khp; July 8th, 2004 at 12:40 PM.
    The biggest problem encountered while trying to design a system that was completely foolproof,
    was, that people tended to underestimate the ingenuity of complete fools.
    Douglas Adams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)


×
By using this site, you agree to the Privacy Policy