处理php和上载文件、上载脚本时出现问题

处理php和上载文件、上载脚本时出现问题,php,uploadify,Php,Uploadify,我有一个php上传脚本的问题 我用的是单一上传器,非多重上传器 下面是我编辑的uploadify.php文件: <?php // Callin require_once("../../includes/functions.php"); connect_db(); check(); // If file exists if (!empty($_FILES)) { $tempFile = $_FILES['Filedata']['tmp_name']; $targetPath = $_SERV

我有一个php上传脚本的问题

我用的是单一上传器,非多重上传器

下面是我编辑的uploadify.php文件:

<?php
// Callin
require_once("../../includes/functions.php");
connect_db();
check();
// If file exists
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
$targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
$ext = pathinfo($_FILES['Filedata']['name'], PATHINFO_EXTENSION);  //figures out the extension
$newFileName = md5($tempFile).'.'.$ext; //generates random filename, then adds the file extension
$targetFile =  str_replace('//','/',$targetPath) . $newFileName;
if($ext == "jpg" || $ext == "gif" || $ext == "png") {
$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 = 180;
$height = 135; // Don't need proportional
$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."../../galleries/vthumbs/".$_FILES['Filedata']['name'],80); // Two folders back to public_html, and /galleries/vthumbs/
break;
case "png":
header("Content-Type: image/png");
imagepng($picture,$targetPath."../../galleries/vthumbs/".$_FILES['Filedata']['name']); // Two folders back to public_html, and /galleries/vthumbs/
break;
case "gif":
header("Content-Type: image/gif");
imagegif($picture,$targetPath."../../galleries/vthumbs/".$_FILES['Filedata']['name']); // Two folders back to public_html, and /galleries/vthumbs/
break;
}
}
imagedestroy($picture);
imagedestroy($image);
}
else {
// If extension isn't jpg or gif or png just move file
move_uploaded_file($tempFile,$targetFile);
}
echo '0'; // Required to trigger onComplete function
}
else { // Required to trigger onComplete function
echo '1'; // For tests 
// mysql_query .........
}
?>
<?php
 if (!empty($_FILES)) {
 $tempFile = $_FILES['Filedata']['tmp_name'];
 $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
 $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name'];
 move_uploaded_file($tempFile,$targetFile);
 echo '0'; // Required to trigger onComplete function
 }
 else { // Required to trigger onComplete
 echo '1';
 }
 ?>
如果需要,我将粘贴javascript代码,调用uploadify.php,但我不需要这样做,因为脚本使用默认的uploadify.php和编辑的uploadify.php no。
欢迎所有的帮助

if(!empty($\u文件))
替换为
if(sizeof($\u文件)>0)
if(!empty($\u文件))
替换为
if(sizeof($\u文件)>0)
逐个添加修改,直到修改中断。然后您将知道哪个修改会破坏原始代码。到那个时候,要么很明显出了什么问题——这是基本的调试!——或者你可以在这里发布一个非常具体的问题。所以我不喜欢“调试我的代码plz”。我已经开始了经典的调试。。。当然不是,PHP很重要。我设置了一个纯粹的巧合,我预测了一个灾难性的错误。设置了一个直接调用上传处理程序页面的测试表单,这样您就可以更容易地捕获输出和调试,而无需javascript层的阻碍。逐个添加您的修改,直到它崩溃。然后您将知道哪个修改会破坏原始代码。到那个时候,要么很明显出了什么问题——这是基本的调试!——或者你可以在这里发布一个非常具体的问题。所以我不喜欢“调试我的代码plz”。我已经开始了经典的调试。。。当然不是,PHP很重要。我设置了一个纯粹的巧合,我预测了一个灾难性的错误设置了一个直接调用上传处理程序页面的测试表单,这样您就可以更容易地捕获输出和调试,而无需javascript层的阻碍。