Solved

Access is Denied error when uploading a file

Posted on 2003-10-29
11
851 Views
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.file.click();
     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>

</form>

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!

Chris
0
Comment
Question by:vable
  • 5
  • 4
11 Comments
 
LVL 58

Expert Comment

by:Gary
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
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 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.
0
 

Author Comment

by:vable
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.
0
 
LVL 58

Expert Comment

by:Gary
ID: 9651320
The browser must be seeing it as an attempt to hack the File tag and hence is not allowing it.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:vable
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.
0
 

Author Comment

by:vable
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.

Thanks,
Chris
0
 
LVL 58

Expert Comment

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

Author Comment

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

Author Comment

by:vable
ID: 9660865
Lunchy,

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.

Chris
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now