A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Problem with image upload script passing variable to php script

  1. #1
    Junior Member
    Join Date
    Mar 2012
    Posts
    4

    Problem with image upload script passing variable to php script

    I am trying to use the adylevy image upload script and have a problem passing a variable from it to the php upload script.

  2. #2
    Junior Member
    Join Date
    Mar 2012
    Posts
    4

    Index page code

    Code:
    <?php
    
    $info = pathinfo($_SERVER['REQUEST_URI']);
    
    $path="http://".$_SERVER['SERVER_NAME'].$info['dirname'];
    if (empty($info['extension']))
    	$path.="/".$info['basename']; 
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    	<head>
    		<title>File Uploader - adylevy.com</title>
    		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    		<script type="text/javascript" src="js/swfobject.js"></script>
    		<script type="text/javascript">
    			var flashvars = {};
    			flashvars.path = "<?php echo $path;?>";
    			var params = {};
    			params.menu = "false";
    			params.scale = "noscale";
    			params.salign = "tm";
    			var attributes = {};
    			attributes.align = "middle";
    			
    			swfobject.embedSWF("swf/imgUpload.swf", "flashHolder", "100%", "100%", "10.0.0", false, flashvars, params, attributes);
    		</script>
    	</head>
    	<body style='background-color:#123456;margin:0px;padding:0px;'>
    		<div id='mainHolder' style='position:absolute;width:100%;height:100%;'>
    			<div id="flashHolder">
    				<a href="http://www.adobe.com/go/getflashplayer">
    					<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
    				</a>
    			</div>
    		</div>
    	</body>
    </html>

  3. #3
    Junior Member
    Join Date
    Mar 2012
    Posts
    4

    PHP Upload script

    PHP upload script. I am able to statically change the $target_path so that the uploads are sent to a different bzp folder. When I try to get an id from the flash index page URL such as ?id=11, the id is blank. Any ideas?

    Code:
    <?php
    set_time_limit ( 240 ) ;
    
    //BlueZone
    $bzp_id="11"; // This Works
    //$bzp_id = htmlspecialchars($_GET['id']); //This doesn't work
    //BlueZone
    
    $file=$_FILES['Filedata'];
    
    for($k=0;$k<count($file['name']);$k++){
    	$target_path = "bzp".$bzp_id."/"; //$target_path = "bzp11/";
    	$target_path = $target_path . basename( $file['name'][$k]);
    	$orig=$target_path;
    	$info = pathinfo($target_path);
    	
    	$ctr=1; 
    	while(file_exists($target_path)){
    		$target_path=$info['dirname']."/".$info['filename'].$ctr.".jpg";//.$info['extension'];
    		$ctr++;
    	}
    	
    	if(move_uploaded_file($file['tmp_name'][$k], $target_path)) {
    	   // echo "status=1&filepath=$target_path&size=".$file['size'];
    	} else{
    	   // echo "status=0&msg=Error";
    	}
    
    }
    
    echo "status=1";
    
    ?>
    Last edited by Travelfrog; 03-23-2012 at 11:03 AM. Reason: added the url id variable

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