SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Location
    U.K.
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Uploading SWF file using php

    Hi all,

    I am building a content management system and need to be able to upload swf files. These files will later be used to play in the browser via an iframe.

    I have a simple script to handle file uploads, that works fine for images. But with the swf files, it is changing the dimensions of the movie (it is making it bigger) and has put a black background to the left and right of the movie (the movie itself has not changed background colour).

    Here is the script:

    PHP Code:
      $handle db_connect();
      
    $number $_REQUEST['number'];
        for (
    $i 1$i <= $number$i++) { 
        
    $element "element$i";
        
    $element_summary "element_summary$i";
            
            
    $type basename($_FILES["$element"]["type"]);
            
    $element_type $_REQUEST['element_type'];
            
              switch (
    $type) {
                case 
    'jpeg':
                case 
    'pjpeg':   
                                
                  
    $query "insert cms_images
                        (type, type2)
                            values                                                           ('
    $element_type','element')";
                
    $result $handle->query($query);
                
                
    $elementid $handle->insert_id;
                                                       
    move_uploaded_file($_FILES["$element"]["tmp_name"],                                     '../images/'.$elementid.'.jpg');
                break;
             case 
    'x-shockwave-flash':   
                  
    $summary $_REQUEST["$element_summary"];   
                   
    $query "insert cms_images
                             (type, type2, summary)
                            values                                                                  ('
    $element_type','element', '$summary')";
                   
    $result $handle->query($query);
                            
                  
    $elementid $handle->insert_id;                        move_uploaded_file($_FILES["$element"]["tmp_name"],                                     '../images/'.$elementid.'.swf');
                 break;
                default:        echo 
    'Invalid picture format: '.                                    $_FILES["$element"]["type"];
                }
              } 
    Does anyone know if there is some problem uploading SWF files in this way? And if so, is there another way of doing it?

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Location
    U.K.
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, I have now found the problem!

    The file upload is not the issue, playing back via an iframe is!

    I have used this instead:

    Code:
    		<object width="640" height="480">
    		<param name="movie" value="images/<?php echo $image;  ?>">
    		<embed src="images/<?php echo $image;  ?>" width="640" height="480">
    		</embed>
    		</object>
    And it works fine now.. although the movie is stuttering quite badly, which I think is an effect of the wrong frame rate.


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
  •