I have this code it uploads photos and deletes photos, but how can i make it to upload photos in a folder i want not in the same folder where the script is, i just can't see where can i implement the path. Here's the whole code:

<?php
/**
 * PHP Gallery Version 1.1
 * Author: Dane Iracleous
 * www.danedesigns.com/phpgallery/
 * This software is freeware. 
 */

//!!Important for proper uploading!!!
ini_set("upload_max_filesize", "100M");
ini_set("post_max_size", "100M");
ini_set("max_execution_time", "600");
ini_set("max_input_time", "600");
ini_set("memory_limit", "1000M");

/*************** EDITABLE VARIABLES *****************/

// number of images to display horizontally in gallery view before new line (integer greater than 0)
$cols = 3;

// number of "browse" boxes for uploading images (integer greater than 0)
$uploadBoxes = 10;

// JPG quality of uploaded images (integer between 1 and 100)
$JPGQuality = 80;

// max size of generated images in pixels (integer greater than 0)
$imageSize = 900;

// max size of generated thumbnails in pixels (integer greater than 0)
$thumbnailSize = 150;

/************ END OF EDITABLE VARIABLES *************/




//!!!!!!!!!!Warning: Do not attempt to change anything below this line unless you are advanced!


// Image resizer class
class thumbnail 
{
    var $img; 

    function thumbnail($imgfile)
    {  
        $this->img["format"]=preg_replace("/.*\.(.*)$/","\\1",$imgfile); 
        $this->img["format"]=strtoupper($this->img["format"]); 
        if($this->img["format"]=="JPG" || $this->img["format"]=="JPEG")
        { 
            $this->img["format"]="JPEG";
            $this->img["src"] = ImageCreateFromJPEG ($imgfile); 
        } 
        elseif($this->img["format"]=="PNG")
        { 
            $this->img["format"]="PNG"; 
            $this->img["src"] = ImageCreateFromPNG ($imgfile); 
        } 
        elseif($this->img["format"]=="GIF")
        { 
            $this->img["format"]="GIF"; 
            $this->img["src"] = ImageCreateFromGIF ($imgfile); 
        } 
        elseif($this->img["format"]=="WBMP")
        { 
            $this->img["format"]="WBMP"; 
            $this->img["src"] = ImageCreateFromWBMP ($imgfile); 
        } 
        $this->img["lebar"] = imagesx($this->img["src"]); 
        $this->img["tinggi"] = imagesy($this->img["src"]);  
    }

    function size_auto($size=100) 
    {
        if($this->img["lebar"]>$size || $this->img["tinggi"]>$size)
        {    
            if($this->img["lebar"]>=$this->img["tinggi"])
            { 
                $this->img["lebar_thumb"]=$size; 
                $this->img["tinggi_thumb"] = ($this->img["lebar_thumb"]/$this->img["lebar"])*$this->img["tinggi"]; 
            } 
            else
            { 
                $this->img["tinggi_thumb"]=$size; 
                $this->img["lebar_thumb"] = ($this->img["tinggi_thumb"]/$this->img["tinggi"])*$this->img["lebar"]; 
            }
        }
        else
        {
            $this->img["tinggi_thumb"] = $this->img["tinggi"];
            $this->img["lebar_thumb"] = $this->img["lebar"];
        } 
    } 

    function jpeg_quality($quality=75) 
    { 
        $this->img["quality"]=$quality; 
    } 

    function save($save="") 
    {  
        if(empty($save)) 
            $save=strtolower("./thumb.".$this->img["format"]); 
        $this->img["des"] = ImageCreateTrueColor($this->img["lebar_thumb"],$this->img["tinggi_thumb"]); 
        imagecopyresized ($this->img["des"], $this->img["src"], 0, 0, 0, 0, $this->img["lebar_thumb"], $this->img["tinggi_thumb"], $this->img["lebar"], $this->img["tinggi"]); 

        if ($this->img["format"]=="JPG" || $this->img["format"]=="JPEG")
            imageJPEG($this->img["des"],"$save",$this->img["quality"]); 
        elseif ($this->img["format"]=="PNG")
            imagePNG($this->img["des"],"$save"); 
        elseif ($this->img["format"]=="GIF")
            imageGIF($this->img["des"],"$save"); 
        elseif ($this->img["format"]=="WBMP")
            imageWBMP($this->img["des"],"$save"); 
    } 
}

// begin execution

if(isset($path)) // display the gallery
{
    $pos = strpos($path, 'gallery.php');
    $path = substr($path, 0, $pos);
    $i=1;
    $dir=dir($path);
    echo "<table cellspacing='0' cellpadding='5' class='gallery_table'>";
    echo "<tr>";

    while($filename=$dir->read()) // get all images from the directory
    {
        if(strpos($filename, "_thumb"))
        {
            echo "<td align='center' class='gallery_td'><a href='".$path.str_replace("_thumb", "", $filename)."' target='_blank'><img src='".$path.$filename."' class='gallery_image'/></a></td>"; 
            if($i%$cols==0)
                echo "</tr><tr>";
            $i++;
        }
    }
   echo "</tr>";
   echo "</table>";
   $dir->close();
}
else
{
        echo "<html>";
        echo "<head>";
        echo "<style type='text/css'>"; //generate the style sheet for the control panel
        echo "
        body
        {
            background-color:#CCCCCC;
            font-family:Verdana, Geneva, sans-serif;
            font-size:14px;
        }
        #container
        {
            background-color:#FFF;
            padding:20px;
            overflow:hidden;
        }
        a
        {
            color:#00F;
            text-decoration:none;
        }
        a:hover
        {
            text-decoration:underline;  
        }
        h1
        {
            margin:0px;
            padding:0px;
            padding-bottom:10px;
        }";
        echo "</style>";
        echo "</head>";
        echo "<body>";
        echo "<div id='container'>";
        echo "<h1>PHP Gallery</h1>";
        echo "<a href='".$_SERVER['PHP_SELF']."?upload=1'>Add Images</a> | ";
        echo "<a href='".$_SERVER['PHP_SELF']."?delete=1'>Delete Images</a> | ";
        echo "<br/><br/>";

        if(isset($_GET['delete'])) //user has deleted an image
        {
            if(isset($_GET['image']))
            {
                unlink($_GET['image']);
                unlink(str_replace("_thumb", "", $_GET['image']));
                echo "'".str_replace("_thumb", "", $_GET['image'])."' has been deleted.<br/><br/>";
            }
            $i=1;
            $dir=dir(".");
            echo "<table cellspacing='0' cellpadding='5' class='gallery_table'>";
            echo "<tr>";
            while($filename=$dir->read()) //display images and 'delete' link underneath each one
            {
                if(strpos($filename, "_thumb"))
                {
                    echo "<td align='center' class='gallery_td'><a href='".str_replace("_thumb", "", $filename)."' target='_blank'><img src='".$filename."' class='gallery_image'/></a><br/><a href='".$_SERVER['PHP_SELF']."?delete=1&image=".$filename."'>Delete</a></td>"; 

                    if($i%5==0)
                        echo "</tr><tr>";

                    $i++;
                }
            }
            echo "</tr>";
            echo "</table>";
            $dir->close();  
        }
        else
        {
            if(!isset($_POST['upload'])) // display upload form
            {
                echo "<form enctype='multipart/form-data' action='".$_SERVER['PHP_SELF']."' method='post'>";
                $i = 0;
                while($i < $uploadBoxes)
                {
                    echo "<input name='userfile[]' type='file' /><br />";
                    $i++;
                }
                echo "<input type='submit' value='Upload' name='upload'/>";
                echo "</form>";
            }
            else
            {
                $success = 0;
                $fail = 0;
                for($i=0;$i<$uploadBoxes;$i++) // process upload form
                {
                    if($_FILES['userfile']['name'][$i])
                    {
                        $uploadfile = basename($_FILES['userfile']['name'][$i]);
                        $unique = time().$i;
                        $ext = strtolower(substr($uploadfile,strlen($uploadfile)-3,3));
                        if(preg_match("/(jpg|gif|png|bmp)/",$ext))
                        {
                            if(move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $unique."_temp.".$ext))
                            {
                                $main=new thumbnail($unique."_temp.".$ext); 
                                $main->size_auto($imageSize);
                                $main->jpeg_quality($JPGQuality);
                                $main->save($unique.".".$ext);

                                $thumb=new thumbnail($unique.".".$ext); 
                                $thumb->size_auto($thumbnailSize);
                                $thumb->jpeg_quality($JPGQuality);
                                $thumb->save($unique."_thumb.".$ext);

                                unlink($unique."_temp.".$ext);
                                $success++;
                            }
                            else
                            {
                                $fail++;
                            }
                        }
                        else
                        {
                            $fail++;
                        }
                    }
                }
                echo "<br> Number of files Uploaded: ".$success;
                echo "<br> Number of files Failed: ".$fail;
            }
        }

        echo "</div>";


        echo "</body>";
        echo "</html>";
    }

?>
Member Avatar

@pucivogel

but how can i make it to upload photos in a folder i want not in the same folder where the script is, i just can't see where can i implement the path

If you want to change the folder you can my question is how long have to work on this script?

Actually i found it on the internet, i think it has to do with line 121 the $path variable...

This is defined in your other post