Hi all!
I'm making an admin, with gallery of photos.
What I am doing is to first create the name of a main photo portfolio with a folder with the name entered and stored within the image that rose.
When ready all the portfolios which are the folders with the main photo, I have a link for gallery.php?portfolio, GET passes the name of the portfolio.
I am now trying to upload images, but don't upload on the folder of portfolio,but save the image to the parent folder
example:
- Portfolio
/Cities

if(file_exists('../portfolio/'.$_GET['portfolio']))
{
   if(!empty($_FILES["gallery_image"]['name']))
   {
     $gallery = "gallery_".rand().".jpg";
     move_uploaded_file($_FILES["gallery_image"]                                       ["tmp_name"],"../portafolio/".$_GET['portafolio']."/" . $gallery);
            $msg.= '<b style="color:green;">Imagen subido.</b>';
    }
    else
    {
        $msg.= '<b style="color:green;">No subio la imagen.</b>';   
    }
      $body .= '<form action="" method="post" enctype="multipart/form-data">';
      $body .= $msg;
      $body .= '<div class="info">';
      $body .= '<p>';
      $body .= '<label>Imagen </label><input type="file" name="gallery_image"/>';
      $body .= '</p>';
      $body .= '<p>';
      $body .= '<input type="submit" value="Subir portafolio" class="submit"                     name="upload"/>';
     $body .= '</p>';
     $body .= '</div>';
     $body .= '</form>';
   }
   else
   {
     $body .= 'Directory does not exist';
    }

In the $ _GET print_r shows me this when I enter eg gallery.php?Cities Array ( [Cities] => ) Thanks and greetings!

Member Avatar for diafol
<?php
if(file_exists('../portfolio/'.$_GET['portfolio'])){
	if(!empty($_FILES["gallery_image"]['name'])){
    	     $gallery = "gallery_".rand().".jpg";
    	     move_uploaded_file($_FILES["gallery_image"]["tmp_name"], "../portafolio/".$_GET['portafolio']."/" . $gallery);
    	     $msg.= '<b style="color:green;">Imagen subido.</b>';
	}else{
             $msg.= '<b style="color:green;">No subio la imagen.</b>';   
        }
?>	
<form action="" method="post" enctype="multipart/form-data">
	<?php echo $msg;?>
	<div class="info">
		<p><label>Imagen </label><input type="file" name="gallery_image"/></p>
                <p><input type="submit" value="Subir portafolio" class="submit" name="upload"/></p>
        </div>';
</form>
<?php
}else{
     $body .= 'Directory does not exist';
}

OK, sorry had to reformat to my understanding.
So, the form only appears if the a folder exists. Is that right?

You seem to have mixed up your destination folders: portfolio and portafolio

Sorry, I'm wrong rather than portafolio is portfolio, but still works wrong

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.