Upload From Folder

Discussion in 'PHP' started by adamjblakey, Oct 20, 2010.

  1. #1
    Hi,

    I have a folder on my server full of images which i want to import into my website. I have the following script running:

    
    //dir_list.php
    $default_dir = "./range"; 
    // lists files only for the directory which this script is run from
    if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");
    while($file = readdir($dp)) 
    {
    if(is_dir($file)) 
    {
    continue;
    }
    else if($file != '.' && $file != '..') 
    {
    	list($title, $ext) = explode('.', $file);
    	$title = $title;
    	$categoryid = 37;
    	$image = uploadimage($file);
    	
    	mysql_query("INSERT INTO `shop_products` (categoryid, title, code, price, rrp, weight, vat_exempt, stock, make, model, active, free_postage, homepage, image, image2, image3, image4, image5, meta_keywords, meta_description, description, sdate) VALUES ('" . $category . "', '" . $title . "', '" . $code . "', '" . $price . "', '" . $rrp . "', '" . $weight . "', '" . $vat_exempt . "', '" . $stock . "', '" . $make . "', '" . $model . "', '" . $active . "', '" . $free_postage . "', '" . $homepage . "', '" . $image . "', '" . $image2 . "', '" . $image3 . "', '" . $image4 . "', '" . $image5 . "', '" . $meta_keywords . "', '" . $meta_description . "', '" . $description . "', '" . $sdate . "')") or trigger_error(mysql_error(),E_USER_ERROR); 
    
    }
    }
    closedir($dp);
    
    PHP:
    Which will import all the products into the database but i want each image to be resized and moved to a different folder on the server also.

    How would i go about doing this? I have a function called uploadimage which i normally use for this but it only handles posted items.

    Cheers,
    Adam
     
    adamjblakey, Oct 20, 2010 IP
  2. Bind

    Bind Peon

    Messages:
    70
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Last edited: Oct 20, 2010
    Bind, Oct 20, 2010 IP
  3. silviuks

    silviuks Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i use verot upload class for handling images. it also works with files that are no uploaded.
     
    silviuks, Oct 21, 2010 IP