How to get Selected file's path of FileUploadField by DirectEvents

  1. #1

    How to get Selected file's path of FileUploadField by DirectEvents

    How to get Selected file's path of FileUploadField by DirectEvents
  2. #2
    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Upload(object sender, DirectEventArgs e)
        {
            string path = this.FileUploadField1.FileName;
            path = MapPath(path);
            X.Msg.Alert("Upload", path).Show();
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:FileUploadField ID="FileUploadField1" runat="server" Width="200">
                <DirectEvents>
                    <FileSelected OnEvent="Upload" />
                </DirectEvents>
            </ext:FileUploadField>
        </form>
    </body>
    </html>
  3. #3

    thank you for help

    thank you for help
  4. #4

    How to get fileUploaderField's posted file's path by Directevents?

    Sorry My english is not good. I believe to help me
    I'm tried it. it work result: my asp project's path + postedFile.Name
    I wanna get postedfile path to image's url. Help
    Last edited by khatnaa_on; Dec 08, 2011 at 1:55 AM.
  5. #5
    Quote Originally Posted by khatnaa_on View Post
    I wanna get postedfile path to image's url.
    Please clarify.
  6. #6

    Same Problem --FileUploadField FullPath

    I get it the same problem as his .

    First:
    The function MapPath(FileUploadField1.FileName) just get the current project's location add the FileUploadField1.FileName,not
    the selected file's fullpath ;Like ,I selected the file :E :/Test/1.jpg, and the project location is D:/Ext/ExtProject, and when I use the MapPath()
    ,I get the path :D:/Ext/ExtProject/1.jpg, ,,but I want get the path :E :/Test/1.jpg .

    Second :how to get the FileUploadField fullpath in code behind use it's ID ,I take " X.GetCmp<FileUploadField>(ID).HasFile " is always null !

    Please help me !
  7. #7
    Quote Originally Posted by nysyzp View Post
    First:
    The function MapPath(FileUploadField1.FileName) just get the current project's location add the FileUploadField1.FileName,not
    the selected file's fullpath ;Like ,I selected the file :E :/Test/1.jpg, and the project location is D:/Ext/ExtProject, and when I use the MapPath()
    ,I get the path :D:/Ext/ExtProject/1.jpg, ,,but I want get the path :E :/Test/1.jpg .
    Well, it's not possible due to browsers security policy - they don't allow to get a file path, only a file name.

    Please clarify what do you need a file path for?

    Quote Originally Posted by nysyzp View Post
    Second :how to get the FileUploadField fullpath in code behind use it's ID ,I take " X.GetCmp<FileUploadField>(ID).HasFile " is always null !
    Please start a new forum thread.

Similar Threads

  1. Replies: 5
    Last Post: Jul 15, 2019, 10:12 AM
  2. Replies: 0
    Last Post: Dec 19, 2011, 9:23 PM
  3. FileUploadField getting the selected file
    By miukarnain in forum 1.x Help
    Replies: 3
    Last Post: Apr 18, 2011, 10:57 AM
  4. Replies: 7
    Last Post: Mar 28, 2011, 5:51 PM
  5. File Path for in Extention Project
    By bsnezw in forum 1.x Help
    Replies: 3
    Last Post: Sep 21, 2009, 6:38 PM

Posting Permissions