A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 22

Thread: uploading with 8

  1. #1
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321

    Angry uploading with 8

    OK I found a tutorial on how to upload with flash 8, I downloaded the php and fla. I tried it a couple days ago with no problems it worked great. so I put the file away and sat on it tell I needed to use it again. I re uploaded the file again to my host and now I get a http error 406. So I remade the swf and php from scratch to make sure it was ok. here is the php and action script I used

    Code:
    //swf action script
    //Allow this domain
    System.security.allowDomain("http://mermadebaubles.com")
    import flash.net.FileReference;
    // The listener object listens for FileReference events.
    var listener:Object = new Object();
    
    // When the user selects a file, the onSelect() method is called, and
    // passed a reference to the FileReference object.
    listener.onSelect = function(selectedFile:FileReference):Void {
      //clean statusArea and details area
      statusArea.text = details.text = ""
      // Flash is attempting to upload the image.
      statusArea.text += "Attempting to upload " + selectedFile.name + "\n";
      // Upload the file to the PHP script on the server.
      selectedFile.upload("upload.php");
    };
    
    // the file is starting to upload.
    listener.onOpen = function(selectedFile:FileReference):Void {
      statusArea.text += "Uploading " + selectedFile.name + "\n";
    };
    //Possible file upload errors
    listener.onHTTPError = function(file:FileReference, httpError:Number):Void {
    	imagePane.contentPath = "error";
    	imagePane.content.errorMSG.text = "HTTPError number: "+httpError +"\nFile: "+ file.name;
    }
    
    listener.onIOError = function(file:FileReference):Void {
    	imagePane.contentPath = "error";
    	imagePane.content.errorMSG.text = "IOError: "+ file.name;
    }
    
    listener.onSecurityError = function(file:FileReference, errorString:String):Void {
    	imagePane.contentPath = "error";
    	imagePane.content.errorMSG.text = "SecurityError: "+SecurityError+"\nFile: "+ file.name;	
    }
    
    // the file has uploaded
    listener.onComplete = function(selectedFile:FileReference):Void {
      // Notify the user that Flash is starting to download the image.
      statusArea.text += "Upload finished.\nNow downloading " + selectedFile.name + " to player\n";
      //Show file details
      details.text = ""
      for(i in selectedFile) details.text +="<b>"+i+":</b> "+selectedFile[i]+"\n"
      // Call the custom downloadImage() function.
      downloadImage(selectedFile.name);
    };
    
    var imageFile:FileReference = new FileReference();
    imageFile.addListener(listener);
    
    uploadBtn.onPress = uploadImage;
    imagePane.addEventListener("complete", imageDownloaded);
    
    // Call the uploadImage() function, opens a file browser dialog.
    function uploadImage(event:Object):Void {
      imageFile.browse([{description: "Image Files", extension: "*.jpg;*.gif;*.png"}]);
    }
    
    // If the image does not download, the event object's total property
    // will equal -1. In that case, display am error message
    function imageDownloaded(event:Object):Void {
      if(event.total == -1) {
        imagePane.contentPath = "error";	
      }
    }
    
    // show uploaded image in scrollPane
    function downloadImage(file:Object):Void {
      imagePane.contentPath =  "./files/" + file;
    }
    
    stop()
    PHP Code:
    <?php
    //create the directory if doesn't exists (should have write permissons)
    if(!is_dir("./files/")) mkdir("./files/"0755); 
    //move the uploaded file
    move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_FILES['Filedata']['name']);
    ?>
    still haveing problems. any one know why some one gets a 406 error?

  2. #2
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    406 error is a server security issue. Your script looks fine to me, although the bit in the php about creating a new directory and setting the permissions for that directory is a bit strange.
    Send me the files, I try it on my server. email

  3. #3

  4. #4
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    yeah I know what you mean by that hole /dir making thing. I even tryed it with making my own /files dir and I removed that out of the php and still nothing. What type of server problems could call a 406 error?

  5. #5
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    who is a good host, I'm so kicking my host to the curb. them some big o A holes!
    I dont even think there is a problem with the script at all any more I think they are having some problems with the ftp permissions I just lost half of some of my images from a /dir and there trying to say I just did it. AAAAAAAAAAHHHHHHHH
    Last edited by joshchernoff; 01-25-2006 at 11:03 PM. Reason: sorry for the type-os it's not fun typeing when your p'd off

  6. #6
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    Quote Originally Posted by joshchernoff
    who is a good host,
    Aside from my company hosting, I love GoDaddy. Their economy hosting package is sencond to none in terms of what you get. Read this:
    Economy Plan: $3.95/mo
    • 5 GB Space • 250 GB Transfer • 500 Email Accounts
    • 10 MySQL Databases • 50 Email Forwards

    Runs php with no problem at all. Choice of Linux or Windows server. Just a great company with tons of customer service. Highly recommended!!

  7. #7
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    what do you think about http://www.mediatemple.net/?

  8. #8
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    Quote Originally Posted by joshchernoff
    what do you think about http://www.mediatemple.net/?
    Looks ok to me. I still like godaddy though.
    Something I found out for you. It's not directly possible to dynamically create a directory and assign a chmod to it. If you get the ownership right, then it wouldn't be an issue, but you need root access to the server and that only comes when you run your own server!! LOL.
    Your code was set to chmod to 755. Mabey try it at 644 for a test and see if it works.

  9. #9
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    I skipped that hole part by just making the directory /files/ in ftp and then I removed the hole make a directory part from the php, yet it don't' seem to make any difference. the big problem is that some the file makes it to the php file but then some how stops because of a 406 error, but I don't know what would stop the php file from moving the file to the right directory. The php file has a full 777 permission to move the file to the right /dir and to also make a directory, but just to avoid any problem with the /files directory I gave that a full 777 permission to read write and so on. The file makes it's way to the php file, I know this because if I try to upload a bigger file it will take a moment to give a 406 error, also I'm seeing a transfer of data on my network connection.



    Did you get it to work for you?

  10. #10
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    So are any files getting to the folder? If so, what size are they? Chances are you have an upload size limit, most hosts regulate this.
    Also, I have really never had luck moving files from directory to directory through php on a shared hosting server. On my own server it's not an issue. Is there a reason that you need to move the files once they are uploaded?

    If you don't need to move the files I have a better script.
    Last edited by launchpad67; 01-26-2006 at 12:57 AM.

  11. #11
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    Flash don't talk to the server in that way so you have to send it to a php file then it go's from that to the /files/ directory. I did have it working before so I know that it's possible.
    the files never gets saved to the /files folder. Somethings wrong with the way that the php gets the file or the way it saves the file.

  12. #12
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    I just tested it on a server and it worked perfectly. Created a folder an set 755 automatically. I stand corrected on what I said before.
    Are you running this at the root level of your site?

    I didn't change this line:
    //Allow this domain
    System.security.allowDomain("http://localhost/");

  13. #13
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    I'v tried it at the root level and in folders and in sub domains. It has to be my host blocking the uploading in the php. I just canned aqhost and switched over to go daddy so well see what happens.
    did you give the hole path to the php file in your action script or just what it had?
    Last edited by joshchernoff; 01-26-2006 at 01:09 AM.

  14. #14
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    Did you see that I didn't change this line in the flash code:
    I didn't change this line:
    //Allow this domain
    System.security.allowDomain("http://localhost/");

    You did! Change it back and try it.

  15. #15
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    I have, and I'v tryed ("http://localhost", "127.0.0.1");

  16. #16
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    No, leave it just the way it came. Like this:
    System.security.allowDomain("http://localhost/");

    Don't add anything at all, just use it like that.

  17. #17
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321
    Quote Originally Posted by launchpad67
    No, leave it just the way it came. Like this:
    System.security.allowDomain("http://localhost/");

    Don't add anything at all, just use it like that.
    what about the upload.php?

  18. #18
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    Quote Originally Posted by joshchernoff
    what about the upload.php?
    All I'm saying is the WHOLE thing works perfectly just like it is written. I didn't change ANYTHING at all and it uploaded an image and created a folder.

  19. #19
    It's a long way to the middle launchpad67's Avatar
    Join Date
    Oct 2004
    Location
    Prescott, Arizona
    Posts
    1,387
    Do you have an IM account with anyone? Yahoo, MSN....

  20. #20
    if($<0){WelcomeToMyWorld} joshchernoff's Avatar
    Join Date
    Jul 2005
    Location
    Portland
    Posts
    321

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

HTML5 Development Center