Results 1 to 7 of 7

Thread: ASPUpload Help!

  1. #1
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ASPUpload Help!

    Hi guys,

    I'm trying to create an admin page where you can upload images, resize them and save them.

    Didn't really want to get into .NET GDI, so I thought I take the easy option and use ASPUpload and ASPJpeg using the following...

    If Page.IsPostBack Then
    Dim Upload = Server.CreateObject("Persits.Upload")
    ' Compute path to save uploaded files to
    Dim Path = Server.MapPath("/images")
    ' Capture uploaded file. Return the number of files uploaded
    Dim Count = Upload.Save
    If Count = 0 Then
    Response.Write("No images selected.")
    Response.End()
    Else
    ' Obtain File object representing uploaded file
    Dim File = Upload.Files(1)
    ' Is this a valid image file?
    If File.ImageType <> "UNKNOWN"Then
    ' Create instance of AspJpeg object
    Dim jpeg = Server.CreateObject("Persits.Jpeg")
    ' Open uploaded file from memory
    jpeg.OpenBinary(File.Binary)
    ' Resize image according to "scale" option.
    ' We cannot use Request.Form, so we use Upload.Form instead.
    jpeg.Width = jpeg.OriginalWidth * Upload.Form("scale") / 100
    jpeg.Height = jpeg.OriginalHeight * Upload.Form(
    "scale") / 100
    Dim SavePath = Path & File.ExtractFileName
    ' AspJpeg always generates thumbnails in JPEG format.
    ' If the original file was not a JPEG, append .JPG ext.
    If UCase(Right(SavePath, 3)) <> "JPG"Then
    SavePath = SavePath & ".jpg"
    EndIf
    jpeg.Save(SavePath)
    Response.Write(
    "Success!")
    Else
    Response.Write("This is not a valid image.")
    Response.End()
    EndIf
    EndIf

    EndIf


    I get an exception though...

    Security Exception

    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.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Source Error:

    Line 5: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadLine 6: If Page.IsPostBack ThenLine 7: Dim Upload = Server.CreateObject("Persits.Upload")Line 8: ' Compute path to save uploaded files toLine 9: Dim Path = Server.MapPath("/images")


    Anyone got any ideas? Looks like permissions, but I thought ASPUpload was enabled on RFH by default?

    Cheers

    Chris

  2. #2
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK, update. I can't seem to create an instance of any component. Any ideas what I'm doing wrong? I get the following when I call the constructor of any component....

    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: System.Security.Permissions.SecurityPermission

    Thanks

    Chris

  3. #3
    Join Date
    Mar 2006
    Posts
    97
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    It may be that your code will not run in a medium trust environment, RFH have there servers running under the medium trust security , thats what it looks like to me anyway.

  4. #4
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It says on the reseller details page that RFH supply ASPUpload and ASPJpeg. Surely if they supply them then they would work? Is it a case of they have to run in asp, not asp.net?

  5. #5
    Join Date
    Jun 2005
    Location
    Tunbridge Wells, Kent
    Posts
    206
    Thanks
    6
    Thanked 2 Times in 2 Posts

  6. #6
    Join Date
    Feb 2004
    Posts
    4,903
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Quote Originally Posted by chrispont
    It says on the reseller details page that RFH supply ASPUpload and ASPJpeg. Surely if they supply them then they would work? Is it a case of they have to run in asp, not asp.net?
    These are ASP/ActiveX components - the .NET Medium Trust security policy prevent the execution of unmanged code, therefore creation of such objects will fail.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  7. #7
    Join Date
    Dec 2005
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    S'alright. Coded it all manually using GDI. Not as quick to do, but a lot more satisfying when it works!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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