Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a solution.</p> <ol> <li>Question A is solved by making the <code>&lt;input type="file" /&gt;</code> the full size of your widget, and using divisions to create non-clickable areas.</li> <li>Question B is solved using the trick I found <a href="http://www.united-coders.com/matthias-reuter/circumvention-of-operas-upload-field-path-protection" rel="nofollow noreferrer">here</a></li> </ol> <hr> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;Style the File Upload Input - Example&lt;/title&gt; &lt;style type="text/css"&gt; #file-upload { position:relative; top:0px; left:0px; width:250px; height:65px; overflow:hidden; padding-top:15px; background-image: url(images/upload_file.gif); background-repeat: no-repeat; background-position: right bottom; } #file-upload input[type='file'] { width:250px; height:65px; font-size:65px; opacity:0; filter:alpha(opacity=0); position:absolute; top:15px; left:0px; z-index:9; } #file-upload input { width:97%; } #file-upload #no-click { position:absolute; bottom:0px; left:0px; z-index:10; width:125px; height:40px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="file-upload"&gt; &lt;input size="0" name="filepc" type="file" id="filepc" onchange="var clone = this.cloneNode(true);clone.type='text';document.getElementById('fakefilepc').value = clone.value?clone.value:this.value;" /&gt; &lt;div id="fake-file-upload"&gt; &lt;input name="fakefilepc" type="text" id="fakefilepc" /&gt; &lt;div id="no-click"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>You might want to worry about graceful degradation... here's the same with the HTML, CSS and JavaScript more cleanly separated which should degrade cleanly.</p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt; &lt;head&gt; &lt;title&gt;Style the File Upload Input - Example&lt;/title&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("body").addClass("js"); $("#file-upload").append("&lt;div id=\"fake-file-upload\"&gt;" + "&lt;input name=\"fakefilepc\" type=\"text\" id=\"fakefilepc\" /&gt;" + "&lt;div id=\"no-click\"&gt;&lt;/div&gt;" + "&lt;/div&gt;"); $("#file-upload input[type='file']").change(function() { var clone = this.cloneNode(true); clone.type='text'; document.getElementById('fakefilepc').value = clone.value?clone.value:this.value; }); }); &lt;/script&gt; &lt;style type="text/css"&gt; #file-upload { position:relative; top:0px; left:0px; width:250px; height:65px; } body.js #file-upload { overflow:hidden; padding-top:15px; background-image: url(images/upload_file.gif); background-repeat: no-repeat; background-position: right bottom; } body.js #file-upload input[type='file'] { width:250px; height:65px; font-size:65px; opacity:0; filter:alpha(opacity=0); position:absolute; top:15px; left:0px; z-index:9; } body.js #file-upload input { width:97%; } body.js #file-upload #no-click { position:absolute; bottom:0px; left:0px; z-index:10; width:125px; height:40px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="file-upload"&gt; &lt;input size="0" name="filepc" type="file" id="filepc" /&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>I was using the following image as the image <code>images/upload_file.gif</code> (and its respective dimensions for everything related thereto)</p> <p><img src="https://i.stack.imgur.com/o6VaO.gif" alt="alt text"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload