-
Problem passing variable from flash upload script to php script
I am trying to integrate a flash upload script by adylevy. I have got the script working and uploading to a folder bzp11 but need to pass a property id number so that the upload can be stored in the correct folder. bzp11, bzp12, bzp13 etc;
I added ?id=11 to the url of the index page. If I manually insert the id number 11 in static php code, it will insert the photos into bzp11 folder OK. When I try to get the number id number 11 from the URL, the upload throws an error.
INDEX page where the flash uploader is.
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>
PHP page where the flash uploader inserts into a specific folder.
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";
?>
-
Hi,
you could try to get a list of received variables.
If you have access to system log file,
Code:
for($_REQUEST as $key => $val) user_error("$key => $val");
Otherwise, create a file
Code:
$fp = fopen("log.tmp", "w");
for($_REQUEST as $key => $val) fwrite($fp, "$key => $val\n");
fclose($fp);
(On unix/linux server make sure that the file could actually be written, e.g. by uploading an empty file and using chmod rw-rw-rw in your ftp program
Musicman
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|