Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Access is Denied error when uploading a file

Posted on 2003-10-29
Medium Priority
Last Modified: 2012-05-04
When developing this file-upload form, I did not run into this problem. I was able to upload files no problem. When I wanted to change the looks and feel of the input file section, I begain recieving this error. Here are the pieces that I am more concern about:

function fileButtonClick()
     document.fileupload.fakefile.value = document.fileupload.file.value;

--in the HTML section--
<form name="fileupload" enctype="multipart/form-data" action="process.asp" method="post" id="fileupload">

<input class="inputReadOnlyFields" type="text" name="fakefile" id="fakefile" />
<span id="browseButton" class="textAsLinks" onclick="fileButtonClick()">Browse</span>
<input type="file" name="file" id="file" style="visibility:hidden" />

For debugging purposes, I put two types of submitting items:

<span id="submitButton" class="textAsLinks" onclick="document.fileupload.submit()">Submit</span>
<button type="submit">Submit</button>


These two react differently (that is why I'm bringing it up). The first one (text) return the access is denied error. The other (the button) just clears out the text in the file field, but does nothing to the fakefile text. If I hit the submit button again, right afterwards, the form is submitted but with no file.

If anyone could help, it would be greatly appreciated!

Question by:vable
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 58

Expert Comment

ID: 9647864
The File tag has security properties e.g you can't set the value for obvious reasons, this is probably why you're getting an error and why it wont let you submit the value.   Otherwise any site I visit could pull files from my pc without my knowing
LVL 58

Accepted Solution

Gary earned 2000 total points
ID: 9647867
In fact not Probably but it Is the reason.  You have to use the File tag properly with its own browse button.

Author Comment

ID: 9650699
I completely agree with your reasoning; however, the server is not assigning a string of a file, the client is. In other words, I when the user clicks on the browse link it activates the browse button of the input tag. Therefore, the input tag is retrieving a string from it (the browse button). I am not reassigning the value of the file tag otherwise I would expect a security error.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 58

Expert Comment

ID: 9651320
The browser must be seeing it as an attempt to hack the File tag and hence is not allowing it.

Author Comment

ID: 9654441
Doing some more debuggin, I found out that the browser does not have a problem with the document.fileupload.fakefile.value = document.fileupload.file.value; piece but rather fact that I am executing the click function of the file tag from javascript. The browser probably thinks that I am "hacking" the user by doing this. If only I can find another way invoking that method.

Author Comment

ID: 9658389
Researching this topic some more, I found out that the only way to have the file tag work properly is the user must click on the Browse button, and not any other way (e.g. using javascript to invoke the click method of the file tag). Also, I cannot format the style of how this tag look (at least not yet), which was my initial content. So, for the question I asked, there is no answer that anyone could give me that would work for this method of formatting or invoking the file tag. However, GaryC123 did give me some information that does explain why I am receiving the error that I have mention.

LVL 58

Expert Comment

ID: 9658422
Well in my second comment I did say you have to use the File tag with its own Browse button.

Author Comment

ID: 9660036
Yes, I realize that. That is why I accepted that comment as the answer.

Author Comment

ID: 9660865

If GaryC123 is complaining about my grade that I have awarded him, fine, I will change it. However, "askers" should have more than 3 options when it comes to grading. Perhaps a number scale of 1 to 100 would be more efficient. Perhaps the webmaster(s) should also put experts' average next to their names; this will tell other people valuable information such as:

What do other people think of this person?
Should I trust this person and spend time doing what he/she suggests?
When grading this person, what kind of grade should I give that will not negatively affect her/his current average?

The reason why I gave this grade was because I did not receive an answer that I was looking for. Perhaps the answer is not the easiest answer; however, to me, it would better than to just "deal with it"

Just send me to the right page to adjust the grade and I will.


Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Loops Section Overview

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question