Solved

file uploader problem in asp.net

Posted on 2011-09-12
3
238 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

920 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

15 Experts available now in Live!

Get 1:1 Help Now