FileUpload with Godaddy

Last post 02-02-2009 11:14 PM by Kumar Reddi. 5 replies.

Sort Posts:

  • FileUpload with Godaddy

    02-02-2009, 8:30 PM
    • Member
      1 point Member
    • poken77
    • Member since 11-13-2008, 1:49 AM
    • Posts 19

     Hi Guys !!

    sure many people had this problem w godaddy before , so i do have it  now but i dont know how to solve it !!

     i want to use teh Fileupload component to on my page to upload a .csv  and read the file (I DONT WANT TO SAVE IT IN THE WEB HOSTING)

    I'am  the Fileupload to upload and read the file line by line in my local env. buy when i try to upload it gives a the following error:

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

     what do i have this error if I am NOT trying to save the file ?

     My code:

      filestream = File.OpenText(System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName.ToString))

            dim readcontents As String
            readcontents = filestream.ReadToEnd()
            Dim rowdelimiter As String
            rowdelimiter = Chr(13) & Chr(10)

    ...............

     p.s the directory were the page is located has read/write permissions

     

    any idea ??

    thanks for your time

    CA

     

  • Re: FileUpload with Godaddy

    02-02-2009, 8:48 PM
    Answer
    • Star
      12,926 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,378

     I am not sure you can open a inmemory file like that. If you want to get a stream, try the StreamReader like the following

     if (FileUpload1.HasFile)
            {
                StreamReader sr = new StreamReader(Request.Files[0].InputStream);

            }

    I know its C#, but you get the point

    Kumar Reddi
  • Re: FileUpload with Godaddy

    02-02-2009, 9:17 PM
    • Member
      1 point Member
    • poken77
    • Member since 11-13-2008, 1:49 AM
    • Posts 19

     it worked,  

    thanks a lot

    p.s. do you know how much data the variable "sr"  will support  or what is going to be my limit?

     

  • Re: FileUpload with Godaddy

    02-02-2009, 9:27 PM
    • Star
      12,926 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,378

     I dont think there is any limit. Its just an in-memory stream. As long as your machine supports the memory of your application, streamreader should be able to read that stream..

    Kumar Reddi
  • Re: FileUpload with Godaddy

    02-02-2009, 10:31 PM
    Answer
    • Contributor
      2,703 point Contributor
    • Rick Matthys
    • Member since 01-20-2009, 3:57 PM
    • Oregon
    • Posts 390

    Hello poken,

    First, you probably already know this but just in case; you have the filestream on your FileUpload control.  So just in case you have more than 1 FileUpload control on your page...

    if (FileUpload1.HasFile)
    {
           StreamReader sr = new StreamReader(FileUpload1.InputStream);
    }

    The two settings you need to worry about maxRequestLength (which specifies the maximum size of your file), and executionTimeout (in case you're uploading large files)

    <httpRuntime
        maxRequestLength="you max size"
        executionTimeout="3600"
    />

    ~Rick

    Please mark the post as ANSWER if it helps you

    Disclaimer: Just my opinion. Not my employer or anyone else....
  • Re: FileUpload with Godaddy

    02-02-2009, 11:14 PM
    • Star
      12,926 point Star
    • Kumar Reddi
    • Member since 11-11-2004, 9:54 PM
    • Virginia
    • Posts 2,378

    Poken,

    Rick is right. I completely forgot about that runtime limitation using the above element. You can place it in the web.config as Rick mentioned.

    Only thing I add is, the total memory consumed by your application can not exceed 60% of your physical memory. For example, if you have 1GB Ram, you can not use more 600 MB approximately. After this memory usage CLR will simply recycle your appdomain. So, that is something to be aware of. But now a days its not a big deal, as the servers come up with huge amounts of RAM

    Kumar Reddi
Page 1 of 1 (6 items)