에 대한 들어갈하지 않으면 내가 길이에 대해 사과, 지금까지 무엇을 가지고 있지만, 이것은 당신에게 완전한 사진 제공 :PHP 다중 파일 업로드 및 생성 썸네일 각 루프 여기
if(count($_FILES['file']['name']))
{
foreach ($_FILES['file']['name'] as $key => $file)
{
$add="../uploads/photogallery/".time().'_'.$file;
$storefile = time().'_'.$file;
echo $storefile; // THIS WORKS
if(move_uploaded_file ($_FILES['file']['tmp_name'][$key],$add))
{
// CODE IS NOT GETTING INTO THIS AREA,
//database insert here
//mysql_query ($query);
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_added">';
}
else
{
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_not_added">';
}
///////// Start the thumbnail generation//////////////
$n_width=150; // Fix the width of the thumb nail images
$n_height=150; // Fix the height of the thumb nail imaage
$tsrc="../uploads/photogallery/thumbnail/".time().'_'.$file;
if (!($_FILES['file']['type'][$key] =="image/pjpeg" || $_FILES['file']['type'][$key] == "image/gif" || $_FILES['file']['type'][$key] == "image/png") || ($_FILES["file"]["type"][$key] == "image/jpeg") && ($_FILES["file"]["size"][$key] < 2097152))
{
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_requirements_not_met">';
}
/////////////////////////////////////////////// Starting of GIF thumb nail creation///////////
if (@$_FILES['file']['type'][$key] =="image/gif")
{
$im=ImageCreateFromGIF($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
if (function_exists("imagegif"))
{
Header("Content-type: image/gif");
ImageGIF($newimage,$tsrc);
}
elseif (function_exists("imagejpeg"))
{
Header("Content-type: image/jpeg");
ImageJPEG($newimage,$tsrc);
}
elseif (function_exists("imagepng"))
{
Header("Content-type: image/png");
ImagePNG($newimage,$tsrc);
}
}
////////////// starting of JPG thumb nail creation//////////
if ($_FILES['file']['type'][$key] == "image/pjpeg")
{
$im=ImageCreateFromJPEG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImageJpeg($newimage,$tsrc);
}
if ($_FILES['file']['type'][$key] == "image/png")
{
$im=ImageCreateFromPNG($add);
$width=ImageSx($im); // Original picture width is stored
$height=ImageSy($im); // Original picture height is stored
$newimage=imagecreatetruecolor($n_width,$n_height);
imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);
ImagePNG($newimage,$tsrc);
}
}
}
else
{
echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_requirements_not_met">';
}
을 그리고 여기에 HTML 부분입니다 형식 :
<input class="input" name="file[]" type="file" id="file" multiple=""/>
예 양식에 올바른 enctype이 있습니다. 위의 코드에서 내 의견을 참조하십시오.이 코드는 작동하고 코드는 아닙니다. 그것이 바로 내 문제입니다. $ storefile을 에코하여 타임 스탬프가있는 올바른 파일 이름을 얻을 수 있기 때문에 각 루프 부분에 들어갈 수 있지만 if (move_uploaded_ ..) 부분에는 들어 가지 않으며 에코 사진 요구 사항을 충족하지 않는 부분은 건너 뜁니다.
도움을 주시면 감사하겠습니다. PHP 또는 MySQL 오류가 발생하지 않습니다. 루프
$_FILES['file']['tmp_name'][$key]
경우와
move_uploaded_file()이 반환 할 내용을 확인하십시오. –
echo move_uploaded_file ($ _ FILES [ 'file'] [ 'tmp_name']); 다음이 종료하고 화면에 아무것도 표시되지 않았습니까? 다른 방법으로 확인할 수 있습니까? –
해당 디렉토리에 쓸 수있는 올바른 권한이 있습니까? 또한, $ _FILES [file] [tmp_name]을'$ _FILES [ 'file'] [ 'tmp_name']로 대체하십시오. "file"은 PHP에서의 함수이며 항상 텍스트 인덱스를 따옴표로 묶어야합니다. 아마도 PHP는 "파일"기능을 실행하고 반환 값을 색인으로 사용합니다 (원하는 내용이 아님). – Optimist