Connecting Tech Pros Worldwide Forums | Help | Site Map

Image Function Problem Function

Familiar Sight
 
Join Date: Sep 2008
Posts: 255
#1: Dec 11 '08
The below function works properly when the its called by:
Expand|Select|Wrap|Line Numbers
  1. storeExtraImages("n","news",1);
But when called by these next two line's it gets to if(move_uploaded_file($_FILES[$img]['tmp_name'], $target_path.$image_name.".".$filetype)) and doesn't move the image and doesn't enter the record into the DB.
Expand|Select|Wrap|Line Numbers
  1. storeExtraImages("r","reviews",2);
  2. storeExtraImages("p","previews",3);
Expand|Select|Wrap|Line Numbers
  1. function storeExtraImages($type,$table,$type_id) {
  2.   if(($_FILES['extra_img_1'] != "") || ($_FILES['extra_img_2'] != "") || ($_FILES['extra_img_3'] != "") || ($_FILES['extra_img_4'] != "") || ($_FILES['extra_img_5'] != "")) 
  3.   {  
  4.     for($i=1;$i<6;$i++)
  5.     {
  6.       $image_name = "";
  7.       $img = 'extra_img_'.$i;
  8.       if($_FILES[$img]['name'] != "")
  9.       {
  10.         $filetype = "png";
  11.         $articleID = getImageID($table);
  12.  
  13.         $target_path = "../images/ex/";
  14.  
  15.         $image_name = $articleID."-".$type."-".getNextImageID();
  16.  
  17.         if(move_uploaded_file($_FILES[$img]['tmp_name'], $target_path.$image_name.".".$filetype))
  18.         {
  19.           mysql_query("INSERT INTO article_images VALUES (NULL,'".$articleID."','".$type_id."','".$filetype."')");
  20.         }
  21.       }
  22.     }
  23.   }
  24. }
Any ideas??

Familiar Sight
 
Join Date: Sep 2008
Posts: 255
#2: Dec 11 '08

re: Image Function Problem Function


Got it sorted, just read another thread there, it looks like its down to the size aloud! :D
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,949
#3: Dec 11 '08

re: Image Function Problem Function


Allowed. :P

I was going to refer you to that thread, but you'd already replied before I could.

Glad you got it sorted,

Markus.
Newbie
 
Join Date: Dec 2008
Location: Montreal, Qc, Canada
Posts: 10
#4: Dec 14 '08

re: Image Function Problem Function


if(($_FILES['extra_img_1'] != "") || ($_FILES['extra_img_2'] != "") || ($_FILES['extra_img_3'] != "") || ($_FILES['extra_img_4'] != "") || ($_FILES['extra_img_5'] != ""))


Should be :

if(($_FILES['extra_img_1']["name"] != "") || ($_FILES['extra_img_2']["name"] != "") || ($_FILES['extra_img_3'] != "") || ($_FILES['extra_img_4']["name"] != "") || ($_FILES['extra_img_5']["name"] != ""))
Reply

Tags
images, php