Page 1 of 1

Upload path problem

Posted: Mon May 07, 2007 6:57 am
by lip9000
I've got an upload script for a photo gallery that I've created which has accepts a URL parameter called 'album' and according to woteva that parameter is finishes the path for the image to be uploaded to. However I'm not sure that the way I've done it is correct because it's not working.
Can someone look at the code and tell me the correct code to replace it with.

$album = $_GET['album'];
$multi_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/mirrabookahs/p/albums/$album/"

As you can see the url parameter album gets assigned to the variable album, then gets inserted into the next line, however does not work. The image just gets uploaded to /mirrabookahs/p/albums. NOTE that the album folder is already created so it's not as if the folder isn't there.

Also I don't get any PHP errors when I run this script, it says the image is successfully uploaded.

Posted: Mon May 07, 2007 7:30 am
by volka
try

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors', true);

if ( !isset($_GET['album']) ) {
  echo '<div>Parameter <i>album</i> missing</div>';
}
else if ( preg_match('![^0-9a-zA-Z-_]!', $_GET['album']) ) {
  echo '<div>only a-zA-Z, digits and dashes allowed in <i>album</i></div>';
}
else {
  $multi_upload->upload_dir = $_SERVER['DOCUMENT_ROOT']."/mirrabookahs/p/albums/$_GET[album]/";
  echo '<div>Debug: upload_dir=', $multi_upload->upload_dir;
}

Posted: Mon May 07, 2007 7:49 am
by lip9000
my script still runs but the image does not get put into that folder. Are the folders allowed to have spaces in them? coz originally i had the upload folder set as 'My Album' and the "Debug: upload_dir" didnt show up. But when i changed it to 'Myalbum' the "Debug: upload_dir" showed the correct location, but again when i run the script it doesn't get put into that folder, or any folder.

I get this other error:

Warning: mkdir() [function.mkdir]: File exists in C:\wamp\www\phpnuke\html\mirrabookahs\admin\gallery\upload_class.php on line 150

I am including a class file which as you can see is trying to create the folder called "$_GET[album]" because it does not exist and it giving me an error due to a bad name.

So again it is not pulling the value of the variable, rather it's actually looking for a folder under the name of "$_GET[album]"