<?
if ( isset($_POST["upload"]) )
{
$video_filename= date("Y-m-d-H-i-s",time()).$_FILES['file']['name'][1];
$file_Name = date("Y-m-d-H-i-s",time()).$_FILES['file']['name'][0];
$uploadfile=$uploaddir.$file_Name;
$pic=$uploadfile;
$Works=$uploaddir.$video_filename;
$filename=$_FILES['file']['name'];
$tmpname=$_FILES['file']['tmp_name'];
echo"$pic";
echo"$Works";
// if(is_uploaded_file($filename2))
//{
for($i=0;$i<count($filename);$i++){
move_uploaded_file($tmpname[$i],$uploaddir.$filename[$i]);
}
$CreateImage =$select.$smallImg.checkExt($_FILES['file']['type'][0]); ImageResize($uploadfile,$toW,$toH,$uploaddir.$CreateImage);
//$sql="insert into `upload_small`(id,title,video,smaller,bigger,storeto,lasttime) values('','$title','$video','$CreateImage','$pic','$select',now())";
echo"$sql";
echo"$Works";
echo"成功";
}function ImageResize($srcFile,$toW,$toH,$toFile="")
{
if($toFile==""){ $toFile = $srcFile; }
$info = "";
$data = GetImageSize($srcFile,$info);
switch ($data[2])
{
case 1:
if(!function_exists("imagecreatefromgif")){
echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!<a href='javascript:go(-1);'>返回</a>";
exit();
}
$im = ImageCreateFromGIF($srcFile);
break;
case 2:
if(!function_exists("imagecreatefromjpeg")){
echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='javascript:go(-1);'>返回</a>";
exit();
}
$im = ImageCreateFromJpeg($srcFile);
break;
case 3:
$im = ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$toWH=$toW/$toH;
$srcWH=$srcW/$srcH;
if($toWH<=$srcWH){
$ftoW=$toW;
$ftoH=$ftoW*($srcH/$srcW);
}
else{
$ftoH=$toH;
$ftoW=$ftoH*($srcW/$srcH);
}
if($srcW>$toW||$srcH>$toH)
{
if(function_exists("imagecreatetruecolor")){
@$ni = ImageCreateTrueColor($ftoW,$ftoH);
if($ni) ImageCopyResampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
else{
$ni=ImageCreate($ftoW,$ftoH);
ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
}
}else{
$ni=ImageCreate($ftoW,$ftoH);
ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
}
if(function_exists('imagejpeg')) ImageJpeg($ni,$toFile);
else ImagePNG($ni,$toFile);
ImageDestroy($ni);
}
ImageDestroy($im);
}
?>
<html>
<head>
<title>文件上传实例</title>
</head>
<body>
<form name="upfile" method="post" action="upload_small.php" enctype="multipart/form-data">
<table border=0 cellspacing=0 cellpadding=0 align="center" width="500">
<tr> <td> 标 题:</td>
<td><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td> 图 片:</td>
<td>
<input name="file[]" type="file" onchange="document.upfile.upfile_path.value=this.value">
<input type="hidden" name="upfile_path"> </td>
</tr>
<tr>
<td> 视 频:</td>
<td>
<input name="file[]" type="file"> </td>
<tr>
<td> </td>
<td><input type="submit" value="上 传" name="upload"></td>
</tr></table>
</form> </body>
</html>
Warning: getimagesize(1/2009-11-10-10-29-231.gif) [function.getimagesize]: failed to open stream: No such file or directory in E:\wamp\www\bbs\upload_small.php on line xxWarning: imagesx(): supplied argument is not a valid Image resource in E:\wamp\www\bbs\upload_small.php on line xxWarning: imagesy(): supplied argument is not a valid Image resource in E:\wamp\www\bbs\upload_small.php on line xxWarning: Division by zero in E:\wamp\www\bbs\upload_small.php on line xxWarning: Division by zero in E:\wamp\www\bbs\upload_small.php on line xxWarning: imagedestroy(): supplied argument is not a valid Image resource in E:\wamp\www\bbs\upload_small.php on line xx
基本都是function ImageResize($srcFile,$toW,$toH,$toFile="")这个函数出错
请教高手这个问题该怎么改啊急死了
if ( isset($_POST["upload"]) )
{
$video_filename= date("Y-m-d-H-i-s",time()).$_FILES['file']['name'][1];
$file_Name = date("Y-m-d-H-i-s",time()).$_FILES['file']['name'][0];
$uploadfile=$uploaddir.$file_Name;
$pic=$uploadfile;
$Works=$uploaddir.$video_filename;
$filename=$_FILES['file']['name'];
$tmpname=$_FILES['file']['tmp_name'];
echo"$pic";
echo"$Works";
// if(is_uploaded_file($filename2))
//{
for($i=0;$i<count($filename);$i++){
move_uploaded_file($tmpname[$i],$uploaddir.$filename[$i]);
}
$CreateImage =$select.$smallImg.checkExt($_FILES['file']['type'][0]); ImageResize($uploadfile,$toW,$toH,$uploaddir.$CreateImage);
//$sql="insert into `upload_small`(id,title,video,smaller,bigger,storeto,lasttime) values('','$title','$video','$CreateImage','$pic','$select',now())";
echo"$sql";
echo"$Works";
echo"成功";
}function ImageResize($srcFile,$toW,$toH,$toFile="")
{
if($toFile==""){ $toFile = $srcFile; }
$info = "";
$data = GetImageSize($srcFile,$info);
switch ($data[2])
{
case 1:
if(!function_exists("imagecreatefromgif")){
echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!<a href='javascript:go(-1);'>返回</a>";
exit();
}
$im = ImageCreateFromGIF($srcFile);
break;
case 2:
if(!function_exists("imagecreatefromjpeg")){
echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='javascript:go(-1);'>返回</a>";
exit();
}
$im = ImageCreateFromJpeg($srcFile);
break;
case 3:
$im = ImageCreateFromPNG($srcFile);
break;
}
$srcW=ImageSX($im);
$srcH=ImageSY($im);
$toWH=$toW/$toH;
$srcWH=$srcW/$srcH;
if($toWH<=$srcWH){
$ftoW=$toW;
$ftoH=$ftoW*($srcH/$srcW);
}
else{
$ftoH=$toH;
$ftoW=$ftoH*($srcW/$srcH);
}
if($srcW>$toW||$srcH>$toH)
{
if(function_exists("imagecreatetruecolor")){
@$ni = ImageCreateTrueColor($ftoW,$ftoH);
if($ni) ImageCopyResampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
else{
$ni=ImageCreate($ftoW,$ftoH);
ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
}
}else{
$ni=ImageCreate($ftoW,$ftoH);
ImageCopyResized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
}
if(function_exists('imagejpeg')) ImageJpeg($ni,$toFile);
else ImagePNG($ni,$toFile);
ImageDestroy($ni);
}
ImageDestroy($im);
}
?>
<html>
<head>
<title>文件上传实例</title>
</head>
<body>
<form name="upfile" method="post" action="upload_small.php" enctype="multipart/form-data">
<table border=0 cellspacing=0 cellpadding=0 align="center" width="500">
<tr> <td> 标 题:</td>
<td><input name="title" type="text" id="title"></td>
</tr>
<tr>
<td> 图 片:</td>
<td>
<input name="file[]" type="file" onchange="document.upfile.upfile_path.value=this.value">
<input type="hidden" name="upfile_path"> </td>
</tr>
<tr>
<td> 视 频:</td>
<td>
<input name="file[]" type="file"> </td>
<tr>
<td> </td>
<td><input type="submit" value="上 传" name="upload"></td>
</tr></table>
</form> </body>
</html>
Warning: getimagesize(1/2009-11-10-10-29-231.gif) [function.getimagesize]: failed to open stream: No such file or directory in E:\wamp\www\bbs\upload_small.php on line xxWarning: imagesx(): supplied argument is not a valid Image resource in E:\wamp\www\bbs\upload_small.php on line xxWarning: imagesy(): supplied argument is not a valid Image resource in E:\wamp\www\bbs\upload_small.php on line xxWarning: Division by zero in E:\wamp\www\bbs\upload_small.php on line xxWarning: Division by zero in E:\wamp\www\bbs\upload_small.php on line xxWarning: imagedestroy(): supplied argument is not a valid Image resource in E:\wamp\www\bbs\upload_small.php on line xx
基本都是function ImageResize($srcFile,$toW,$toH,$toFile="")这个函数出错
请教高手这个问题该怎么改啊急死了
$file_Name = date("Y-m-d-H-i-s",time()).$_FILES['file']['name'][0];
$uploadfile=$uploaddir.$file_Name;
//但你实际从临时目录复制到的真正路径却是$uploaddir.$filename[$i]
move_uploaded_file($tmpname[$i],$uploaddir.$filename[$i]); 如果$uploadfile 和 $uploaddir.$filename[$i] 不相等,就是有问题的.
ImageResize函数读取的是$uploadfile,但实际上你真正的文件是$uploaddir.$filename[$i],所以导到找不到文件.