Jump to content

multiple upload problem


airdee

Recommended Posts

hi. i have this snippet that uploads only one file. i wanted to upload multiple files and save the filename to the database. i am trying to figure out how i can do it. i modified the code by adding a for loop and change $img1_name  to $img[$i]_name but it doesn't work. im having error: Parse error: parse error, unexpected T_STRING in ...\process.php on line 66. how is the way to do this? here's a part of the code.

[code=php:0]
  for ($i = 1; $i <= $num_files; $i++) {
    if($img[$i]_name!=""){
$limit_jpg = "200000";
$ext_count = "4";
$extensions = array(".jpg",".jpeg",".JPG",".JPEG");
$ext = strrchr($img[$i]_name,'.');
if(!in_array($ext,$extensions)) {
echo "<SCRIPT>alert(\"File is wrong type! .JPG only!\")</SCRIPT><script>history.go(-1)</script>";
}elseif(($ext == ".jpg") && ($img[$i]_size < $limit_jpg)){
$getlisting1=0;
$getlisting1 = $db->getone("select max(id) from listings"); 
$getlisting=$getlisting1+1;
$imagefile = $getlisting.".jpg";
if($i==1) $img1=$imagefile;
if($i==2) $img2=$imagefile;
if($i==3) $img3=$imagefile;
if($i==4) $img4=$imagefile;
if($i==5) $img5=$imagefile;
if($i==6) $img6=$imagefile;
if($i==7) $img7=$imagefile;
if($i==8) $img8=$imagefile;
$imagepath="../uploads/";
copy("$img1","$imagepath$imagefile") or die("Could not copy file");
thumbnail("$imagepath/$imagefile",150,"$imagepath/","tn_$imagefile");
imglarge("$imagepath/$imagefile",400,"$imagepath/","$imagefile");
}else{
echo "<SCRIPT>alert(\"File too Large to upload!\")</SCRIPT><script>history.go(-1)</script>";
}
    }
  }
[/code]
Link to comment
https://forums.phpfreaks.com/topic/26031-multiple-upload-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.