tags:

views:

31

answers:

0

Hello, I have the following code in uploadLogo.asp:

<%
Set Upload = Server.CreateObject("Persits.Upload")
' we use memory uploads, so we must limit file size
Upload.SetMaxSize 100048576 ' Limit files to 100MB

' Save to memory. Path parameter is omitted
Upload.Save

' Check whether a file was selected
Set File = Upload.Files("Filedata")
If Not File Is Nothing Then
 ' Obtain file name
 Filename = file.Filename

 Dim extension
 extension = Mid(Filename, InstrRev(Filename, ".") + 1)
 extension = LCASE(extension) 



 If(extension = "png" or extension = "gif" or extension = "jpeg" or extension = "jpg") then
  'check if file exists in ..\provesUpload\ under this name
  File.SaveAsVirtual "../LogoFiles/" & File.FileName

  Response.write "OK"
 Else 
 Response.write "KO"
 End If
End If

%>

And the following in Uploader.as (AS2):

import flash.net.FileReference;

class Uploader

{
 private var allTypes:Array;
 private var textTypes:Object;
 private var uploadListener:Object;
 private var fileRef:FileReference;


 public function Uploader() 
 {
  var dis = this;

  allTypes = new Array();
  textTypes = new Object();
  textTypes.description = "Upload files (*.jpg; *.png; *.gif; *.jpeg)";
  textTypes.extension = "*.jpg; *.png; *.gif; *.jpeg";
  allTypes.push(textTypes);

  uploadListener = new Object();
  uploadListener.onSelect = function(file:FileReference):Void {
   file.upload(myPath + "/asp/uploadLogo.aspx");

   if(!file.upload(myPath + "/asp/uploadLogo.aspx")) {
    trace("Upload dialog failed to open.");
   }
  }
  uploadListener.onCancel = function(file:FileReference):Void {
   trace("onCancel");
  }

  uploadListener.onOpen = function(file:FileReference):Void {
   trace("onOpen: " + file.name);
  }

  uploadListener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
   trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal + " de " + file.name);
  }

  uploadListener.onComplete = function(file:FileReference):Void {
   trace("onComplete: " + file.name);
  }
  uploadListener.onUploadCompleteData = function(file: FileReference, data: String) {
   trace("onUploadCompleteData");
  }
  uploadListener.onHTTPError = function(file:FileReference, httpError: Number):Void {
   trace(file.name + " onHTTPError: " + httpError);
  }



  uploadListener.onIOError = function(file:FileReference):Void {
   trace("onIOError: " + file.name);
  }

  uploadListener.onSecurityError = function(file:FileReference, errorString:String):Void {
   trace("onSecurityError: " + file.name + " errorString: " + errorString);
  }
  fileRef = new FileReference();
  fileRef.addListener(uploadListener);
  fileRef.browse(allTypes);
 }
}

And when I execute this code, I recieve the following trace:

onOpen: image.jpg
onProgress with bytesLoaded: 32768 bytesTotal: 47212 de image.jpg
onProgress with bytesLoaded: 47212 bytesTotal: 47212 de image.jpg
image.jpg onHTTPError: 500

Someone can help me please?