Results 1 to 3 of 3

Thread: Upload script not working on server but fine locally

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Location
    Newark-on-trent, Nottingham
    Posts
    243

    Upload script not working on server but fine locally

    Code:
            If FileUpload1.HasFile Then
                Dim filepath As String = FileUpload1.PostedFile.FileName
                Dim pat As String = "\\(?:.+)\\(.+)\.(.+)"
                Dim r As Regex = New Regex(pat)
                'run
                Dim m As Match = r.Match(filepath)
                Dim file_ext As String = m.Groups(2).Captures(0).ToString()
                Dim filename As String = m.Groups(1).Captures(0).ToString()
                Dim file As String = filename & "." & file_ext
    
                'save the file to the server 
                FileUpload1.PostedFile.SaveAs(Server.MapPath("../images/") & file)
                lblMsg.Text = "File Uploaded!"
            End If
    Works a charm locally but as soon as i upload this to the live server (hosted by heart internet) i get:

    Code:
    Server Error in '/' Application.
    
    Specified argument was out of the range of valid values.
    Parameter name: i
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: i
    Any advise???

  2. #2
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Upload script not working on server but fine locally

    Are you sure that the permission settings on your server allow you to upload files there?
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Upload script not working on server but fine locally

    Hello,

    Is it possible for you to do some remote debugging on this server? Or how about adding some logging to your application?

    If would be good to know exactly what line it is failing on, and the associated values of each of the variables in use.

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width