dropdown.php:
Code: Select all
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Uploadify scriptData Sample</title>
<link rel="stylesheet" href="uploadify/uploadify.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#fileUpload2").fileUpload({
'uploader': 'uploadify/uploader.swf',
'cancelImg': 'uploadify/cancel.png',
'script': 'uploadify/upload.php',
'folder': 'files',
'multi': true,
'buttonText': 'Select Files',
'checkScript': 'uploadify/check.php',
'displayData': 'speed',
'simUploadLimit': 4
});
});
</script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: "GET",
url: "galleries.xml",
dataType: "xml",
success: function(xml) {
var select = $('#mySelect');
$(xml).find('category').each(function(){
var title = $(this).find('title').text();
select.append("<option>"+title+"</option>");
});
select.children(":first").text("please make a selection").attr("selected",true);
}
});
});
</script>
</head>
<body>
<h2>Multiple File Upload</h2>
<div id="fileUpload2">You have a problem with your javascript</div>
<form action="uploadify/xmlnamer.php" method='get'>
<select name="selectBox" id="mySelect" onchange="this.form.submit()">
<option>loading</option>
</select>
</form>
<a href="javascript:$('#fileUpload2').fileUploadStart()">Start Upload</a> | <a href="javascript:$('#fileUpload2').fileUploadClearQueue()">Clear Queue</a>
</body>
</html>
Code: Select all
<?php
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_GET['folder'] . '/';
$targetPath = str_replace('//','/',$targetPath);
$targetFile = $targetPath . $_FILES['Filedata']['name'];
move_uploaded_file($tempFile,$targetFile);
}
$imgsize = getimagesize($targetFile);
switch(strtolower(substr($targetFile, -3))){
case "jpg":
$image = imagecreatefromjpeg($targetFile);
break;
case "png":
$image = imagecreatefrompng($targetFile);
break;
case "gif":
$image = imagecreatefromgif($targetFile);
break;
default:
exit;
break;
}
$width = 80; //New width of image
$height = $imgsize[1]/$imgsize[0]*$width; //This maintains proportions
$src_w = $imgsize[0];
$src_h = $imgsize[1];
$picture = imagecreatetruecolor($width, $height);
imagealphablending($picture, false);
imagesavealpha($picture, true);
$bool = imagecopyresampled($picture, $image, 0, 0, 0, 0, $width, $height, $src_w, $src_h);
if($bool){
switch(strtolower(substr($targetFile, -3))){
case "jpg":
header("Content-Type: image/jpeg");
$bool2 = imagejpeg($picture,$targetPath."Thumbs/".$_FILES['Filedata']['name'],80);
break;
case "png":
header("Content-Type: image/png");
imagepng($picture,$targetPath."Thumbs/".$_FILES['Filedata']['name']);
break;
case "gif":
header("Content-Type: image/gif");
imagegif($picture,$targetPath."Thumbs/".$_FILES['Filedata']['name']);
break;
}
}
imagedestroy($picture);
imagedestroy($image);
echo '1'; // Important so upload will work on OSX
$str = $_FILES['Filedata']['name'];
$fp = fopen($dor, 'a+');
fwrite($fp, $str);
fclose($fp);
echo '1';
?>
Code: Select all
<?php
$dor = $_GET["selectBox"];
header("Location:http://mydomain.com/imgupload/dropdown.php");
?>