Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Problem moving uploaded image to a folder!

images php coding issues or problems here.

Moderators: macek, egami, gesf

Problem moving uploaded image to a folder!

Postby ellerforums » Mon Feb 06, 2012 1:44 pm

I already used move_uploaded_file but its not working...help!!!

Code: Select all
<?php
if  (isset($_POST['cathegory'] , $_POST['name'] , $_POST['description'] , $_FILES['image_1'] , $_FILES['image_2'] , $_FILES['image_3'])){
   $name = $_POST['name'];
    $cathegory = $_POST['cathegory'];
    $description = $_POST['description'];
    $image_1 = $_FILES['image_1'];
    $image_2 = $_FILES['image_2'];
    $image_3 = $_FILES['image_3'];
    $image_1_name = $image_1['name'];
    $image_2_name = $image_2['name'];
    $image_3_name = $image_3['name'];
    $image_1_tmp = $image_1['tmp_name'];
   
    }
   
   if  (empty($name) or empty($description)) {
      echo  'Complete all information please' ;
   
   }    elseif(substr($image_1['type'],0,5) != 'image' or substr($image_2['type'],0,5) != 'image' or substr($image_2['type'],0,5) != 'image') {
      echo 'please upload images only';
   
   }      elseif (strlen($name > 55) or strlen($description > 255)){
         echo 'Name of description field contains too many characters.';
   
   }          else {
            echo 'Starting images process :D <br>'  ;
            echo $cathegory.'<br>'  ;
            //echo $image_1_name ;
            
            $directory = "$cathegory/$name";
            if (!is_dir ($directory)) {
                 //file mode
                 $mode = '0775';
                 //the third parameter set to true allows the creation of
                 //nested directories specified in the pathname.
                 mkdir($directory, $mode, true);
                 chmod($directory, 0777);
                 
                move_uploaded_file($image_1_tmp , $directory.'/'.$image_1_name);
                 
            }
            

            
   }

?>
ellerforums
New php-forum User
New php-forum User
 
Posts: 1
Joined: Mon Feb 06, 2012 1:40 pm

Return to PHP coding => Images

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.