.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Get Full Value of Fileupload path

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
Hi, I have a file upload control on my webform. When I want to use it to select a text file. I will not be uploaded the file however, I will need the value of the path so I can open the text file with the streamreader. I then will pass the value of the text file to a database. How do I get the value of the fileupload textbox?  Here is my code so far:   Dim FILENAME As String = NEED VALUE OF FILEUPLOAD TEXTBOX VALUE HERE Dim myfile As String Dim objStreamReader As StreamReader objStreamReader = File.OpenText(myfile.Text) Dim contents As String = objStreamReader.ReadToEnd() t.Text = contents objStreamReader.Close() 

View Complete Post

More Related Resource Links

get full path from fileupload control in client side???


<script type="text/javascript" >

        function SetA()

                    document.form1.action = 'Default.aspx?fileName='+document.getElementById('FileUpload1').value;
    <form id="form1" runat="server">
        <asp:FileUpload ID="FileUpload1" runat="server"  />
        <asp:Button ID="btnupload" runat="server" Text="Upload" OnClientClick="SetA()" />



here in the  javascript function i need send full path of upload control?


please help in this situation? if anybody knows other way of sending full path please tell?


thank you,

FileUpload.SaveAs is configured to require a rooted path. but "http:// --- is not a rooted path


Hi Friends

when i am uploading image to http://filepath i got the 

The FileUpload.SaveAs Method is configured to require a rooted path but http:// filepath is not a rooted path

my code is as follows

If (Fileupload.HasFile)


Dim filepath As String = http://filepath/

FileUpload.SaveAs(filepath & String.Format("datafield_{0}_b.jpg", textbox.Text))

End If

Please help me




How to capture the full file path from Async File Uploader Control?

Hi,I have an Async File Uploader control inside a Repeater which is inside an update panel.Now,I am uploading the file into ftp,so I am not uploading the video file,using SaveAs() method.For uploading the file in ftp,I have this UploadFile method which takes these four parameter:FileName, UploadPath, FTPUser, FTPPassword.Now this FileName,I have to send the full file path. My UploadComplete event looks like this:<pre lang="cs">protected void AsyncVideoUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)      {//VideoPath is a session variable            VideoPath = string.Empty;            if (AsyncVideoUpload.HasFile)            {               // string filepath = AsyncVideoUpload.PostedFile.FileName;                  string filepath = e.filename;//above two captures only the file name,but I want the total path,like c:/MyDocuments/...                                 UploadFile(filepath, "","test","Value*12"); &

getting full path of file


i am using fileupload javascript control and i want to get i want to get full path of file rather than file name is their any one help me

eg. i m going to select file from c drive it shows only file name rather than full path

this is my code

function preview(field) {
field = document.getElementById( 'upload' ).value;
alert("Before:"+field); //--> this was comment by me
image = document.getElementById( 'previewIMG' );

path = 'file:///'+ field;
path = escape(path);
path = path.replace(/%5C/g, "/");
path = path.replace(/%3A/g, ":");

alert("after="+path); //--> this was comment by me
image.src = path;
image.style.display = 'block';
image.style.width = "200px";
image.style.height = "150px";


<input type="file" name="upload" id="upload" onChange="preview(this.value)"; />
<input type="submit" name"submit" value="Upload Me Now">
<img id="previewIMG" style="display:none;" />

FileUpload path problem


I have not been able to uplaod a file to my web page although the code I am using works if I copy it locally. Perhaps I am missing something in the path or I need to change some security setting on the web page?

   protected void btnUpload_Click(object sender, EventArgs e)
        SelectedFileName.InnerHtml = txtFileField.PostedFile.FileName;
        FileType.InnerHtml = txtFileField.PostedFile.ContentType;

        // convert bytes to Kbytes
        int size = txtFileField.PostedFile.ContentLength / 1024;
        FileSize.InnerHtml = (size.ToString() + " KB");
        uploadDetails.Visible = true;

        string strFileName = txtFileField.PostedFile.FileName;
        string c = Path.GetFileName(strFileName);

            // not sure if this path is correct. not working anyway
            txtFileField.PostedFile.SaveAs("~/" + c); 
            feedBack.InnerHtml = "File uploaded successfully.";
        catch (Exception exp)
            string message = "File did not upload, please try again";
            feedBack.InnerHtml = message + "\n" + exp.Message.ToString();
            uploadDetails.Visible= false;
Thanks for any help.

Input type file-: Not getting full path in mozilla


Hi All

I am using Input type = File to get a file from Disk.

<input type=file id="ipFile">

But when i get the value of this i get a file name in Mozilla where as a complete path with file name in I.E.


In I.E. -: D:\bkp\css.txt

In Mozilla -: css.txt

I want to get the Full path in Mozilla too. 

Please help and advice

Start project from view => full view path appended to the URL => 404



If I start the project while in a view, it appends that view name (and path) to the URL, and I get a 404 error.


If I then switch to any non-view, like the controller and hit F5, it starts up with no additional URL and gets routed to the default controller.


 Is there a way to fix this? Is it an option (to not pass the view url on debug), or a routing cfg issue? I'm no MVC expert.

routes.MapRoute(	"Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } );

Thank you 

site created from template but URL results in 404 unless full path is used


I'm fairly new to Sharepoint 2010, but after two days of playing around with this, I feel like I've tried all possible permutations and need some assistance.  Here is the scenario:

Basically, we have a site, a blank site, created by a predecessor, that we've been using as a 'template' for new subsites.  It's not a real template though, native to Sharepoint, it's an actual subsite that we use stsadm.exe to import. (STSADM.EXE -o import -url http://aaaaa/bbbbbbb/NewToolName -includeusersecurity -filename C:\ddddddddd\ffffffffff.dat).

Unfortunately, our server is about to be absorbed into a larger Sharepoint farm, and we'll no longer have access to the box, to run direct admin commands.

I've been testing the actual template functionality, and it's coming up far short of what we currently get by importing that site via cmd line.  What I've done is essentially saved that blank site as a template, then tested it by creating sites based on that template.  And it's pretty messy!

- permission are lost (noted in the help so that's not unexpected, just inconvenient)
- subsites don't carry over--in this case, a blog
- links don't function properly, due to a relativity issue,

How Do I: Get [Flash Desk] full path on handheld pc?


hi all

how are you??


i'm using c# in v.s 2005

i need to get full file path on handheld pc that using windows ce 5.00

i try to do that using [open file dialog] but i got a path as temporary internet file on drice c.


thanks in advance

Sharepoint/SSRS: The full path must be less than 260 characters long

Question: I setup a dual server Sharepoint deployment with SSRS and now I keep getting the error like the one below when I try to save a report or a datasource on the server:

The path of the item 'http://intranet/sharepoint/CompanyReports/MyReports' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash.

I'm looking into permissions but this happens regardless of authentication I select on the client end.

PDA Keyboard v1.0 Light Edition - Full Screen Keyboard

The default keypad on Windows Mobile is not at all finger friendly, there is no way you can use it with your fingers. I have trouble using the stylus with it too. But there are many freeware option available to make the SIP ( Software Input Panel - check the Glossary ) finger friendly. Some of these are HTC Diamond keyboard, Blimkeys, PocketCM Keyboard and then now we have PDA Keyboard v1.0 Light Edition from pdamedia.biz. When you hit the blue button it goes into fullscreen mode , then you can use both your hands for typing.

Virtual Path Problem


 I get the following error on last line below (working on remote host): 'E:\web\sfcascom\ls_admin/uploads/images/001.JPG' is not a valid virtual path,

Note that the slashes go in different directions

I've tried a number of things but nothing seems to work. Thanks-


Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Drawing.Imaging
Imports System.Web.UI.WebControls

Imports System.Drawing.Imaging.ImageCodecInfo
Partial Class Protected_imageupload
    Inherits System.Web.UI.Page
    Private Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        ' Initialize variables
        Dim sSavePath As String
        Dim sThumbExtension As String
        Dim intThumbWidth As Integer
        Dim intThumbHeight As Integer
        Dim sFilename As String = ""
        ' Set constant values
        'sSavePath = "images/"
        sSavePath = Server.MapPath("~/") + "ls_admin/uploads/images/"

        sThumbExtension = "_thumb"
        intThumbWidth = 160
        intThumbHeight = 120

        ' If file field isn?t empty
        If FilUpload.PostedFile IsNot Nothing Then
            ' Check file size (mustn?t be 0)
            Dim myFile As Http

Server side validation of Fileupload control not working



I've tried this method in my code behind to try and validate that the Fileupload control has a file or not. I get the error message the the event "Server Validate" cannot be found. Can anyone tell why? Thanks.

Public Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate

' Get file name

        Dim uploadAvatar As FileUpload = DirectCast(AdvertisementForm.FindControl("uploadAvatar"), FileUpload)

        Dim UploadFileName As String = uploadAvatar.PostedFile.FileName

        If UploadFileName = "" Then
            ' There is no file selected
            args.IsValid = False
            Dim Extension As String = UploadFileName.Substring(UploadFileName.L

Creating a user friendly alias for the website path


 Hello mates,

I am hosting my ASP.NET application on a Windows 2003 Server.

To browse to my application one has to type the path :http://serverName/applicationName

I want users to only type  applicationName on the web adress area.I believe there is something to do with alias and CNAME on DNS records that can adress this.

Any help on how to go about doing this will be highly appreciated.

Is this load full or matching one only... coz of need to know performance



This my Two Table i have one doubt...

For my first table i have select Top 2 from Employee_info 

and second table itz just selct * from MDEp..

What my doubt is on loading the above report?

Is this load all the record from MDep or just matching one based on Employee_info..?

How to set SearchRoot Path in Active Directory in this scenario


How to set SearchRoot Path in Active Directory in this scenario:

Functionality: We have scenario that 1<sup>st</sup> hit one LDAP server with some 'fixed user name' &' fixed password ' and filter data with specific User name(which given by user) getting 'User dn'.

After that we hit Next LDAP server based on the 'User dn' getting from 1<sup>st</sup> server.

(So, in my case 1<sup>st</sup> LDAP server works like as Load balancing server but functionalitywise it is different)


Split URL/Path in Classic AND .net 2.0


I need to be able to get the different parts of the URI (and convert from/to relative page paths) in BOTH classic ASP and .Net 2.0 (VB).

For example, if I have "http://sitename.company.com/index.aspx?sec=fred&pag=dis&mode=1" OR "/index.aspx?sec=fred&pag=dis&mode=1"

IS there a function where I can pass in either string (assuming I'm on sitename.company.com) and get back an array with:

(0): sitename.company.com
(1): index.aspx
(2): sec=fred&pag=dis&mode=1

(Or, alternately, three different functions that would return the three parts?)


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend