Solved

file uploader problem in asp.net

Posted on 2011-09-12
3
237 Views
Last Modified: 2012-05-12
I have two users on our local network.  I'm trying to do the following:
System.IO.Path.GetDirectoryName(fuFileName.PostedFile.FileName).ToLower

On one machine I am getting the directory name.  On the other I am getting nothing.  I tried just printing out fuFileName.PostedFile.FileName.ToLower on the machine I can use the above statement on I'm getting the full path and file name.  On the other I'm getting only the filename.

The code is successful on several computers running ie7 and ie8 but this particular one (running ie 8) will not work.  I have read that secruity reasons will prevent the client path to be returned but then i also read it will work on the local network.  the reason I want it is because the file needs to come from one central location on the server.  I'm using the fileuploader control not really as a file uploader but as a file picker.

Hope this makes sense.  I'm thinking there is some security setting in ie 8 preventing this from working.
0
Comment
Question by:Fraser_Admin
3 Comments
 

Author Comment

by:Fraser_Admin
ID: 36524211
one other thing...this computer does not have any internet access.  the other computer that it works on do have internet access.  not sure if that is what could be causing the problem or not.  but it is the only thing other than the versions I have found that are different.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36526211
What is the current security zone selected on IE8 on that computer? Is it same as other computers?
0
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 36526340
If you don't really want to upload the file you may want to use client-side javascript to stop the file from being sent to the server. Also you can copy the file name to a hidden field so that your problem might be solved.

<html>
 <head>
  <script type="text/javascript">
   var savObject = null;
   function copyValue(oFile) {
    savObject = oFile;
    if (oFile.value != '') {
     oFile.form.elements['copiedFile'].value = oFile.value; // save full path to file in hidden form element
    }
   }
  function checkSubmit(oForm) {
   if (savObject != null) {
     savObject.disabled = true; // don't send file
     oForm.elements['sbm'].disabled = true; // prevent double click and also don't send value of button...
     return true;
    } else {
     return false;
    }
   }
  </script>
 </head>
 <body>
  <form name="fileUpload" method="post" action="save.php" onsubmit="return checkSubmit(this)">
   <input type="hidden" name="copiedFile">
   <input type="file" name="origfile" onblur="copyValue(this)">
   <br><br>
   <input type="submit" name="sbm" value="Save">
  </form>
 </body>
</html>

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 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

11 Experts available now in Live!

Get 1:1 Help Now