Upload to different directories

See all posts Reply

Upload to different directories new!
by Rene Buruma, 15 years, 7 months ago
I want to us this php script to integrate an image library for all my birds. Each bird has a unique number. I call the upload.php like this:
form name="form2" enctype="multipart/form-data" method="post" action="upload.php?upload_dir="

I am retrieving this value in upload.php like this:
$dir = $_GET['upload_dir'];

Then I want the image to be uploaded to the correct directory using the value of $dir. Something like this:
$handle->Process('./jGallery/albums/$dir');

But this doesn't work.

Can anyone help me out on this ?

Kins regards,

ReneReply
Re: Upload to different directories new!
by colin, 15 years, 7 months ago
You should use a hidden field for upload_dir. But really, it is a very unsecure way to do. You'd better have a list of possible directories in your form, in a select list for instance, and then in your PHP code translate the user's choice into a real directory.

In any case, this is a PHP issue, and doesn't really belong here.Reply
Re: Upload to different directories new!
by Rene Buruma, 15 years, 7 months ago
Because I am using this locally on my own PC security is no issue for me. The problem is that usingthis syntax:
$handle->Process('./jGallery/albums/$dir');

will create a new directory called $dir in stead of a new directory withteh value of $dir (for exampel 4 if I want to upload an image for bird number 4.Reply
Re: Upload to different directories new!
by colin, 15 years, 7 months ago
Simply do:
$handle->Process("./jGallery/albums/$dir");

or:
$handle->Process('./jGallery/albums/'.$dir);
Reply
Re: Upload to different directories new!
by Rene Buruma, 15 years, 7 months ago
Thanks Colin,

This works perfect. I am not a very experienced php programmer. Thanks again for your help.

ReneReply