Hi all,
I was hoping someone coulding she a bit of light on some strangely disappearing variables!
I am using php to recieved and process uploaded files into local folders for a dynamic gallery site. the picture information & categorisation, i intend to store in a mysql database and i'm using flex from my front end - which will process xml generated by php to sort out various albums.
my first approach was to try and create seperate folders for each album upload. here is the script:
<?php
mkdir("program_code/" . $REQUEST['albumname'] . "/");
$target_path = "root/program_code/" . $REQUEST['albumname'];
//$target_path = $target_path
$target_path = $target_path . "/";
$target_path = $target_path . basename( $_FILES['Filedata']['name']);
move_uploaded_file($_FILES['Filedata']['tmp_name'], $target_path);
?>
the $_REQUEST['username'] passes in successfully my problem is - the files save in the program_code/ directory, not the newly created directory from the albumname variable - it's like php chooses to ignore it. i understand move_uploaded_file on windows acts on the root directory, so i tried putting in a literal path like root/program_code/pics whilst passing in pics as a request parameter - surely enough, the folder is created and images upload to the pic directory - php just refusess to see it or process it in time when passed in as a reuest parameter for the move_uploaded_file method
so i tried a different approach - creating unique hashed filenames for each uploaded file and storing the names into a newly created mysql table which takes the albumname request parameter as it's name. here is the code:
<?php
include("config.inc.php");
$uploaddir = "images/";
$file = $_FILES['Filedata'];
$name = sha1_file($file['tmp_name']);
$pathInfo = pathinfo($file['name']);
$name .= '.'.$pathInfo['extension'];
move_uploaded_file($file['tmp_name'], $uploaddir.$name);
$q = <<<CREATE
create table $_REQUEST[username](
photo_id bigint(20) unsigned NOT NULL auto_increment,
photo_filename varchar(80),
photo_category bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (photo_id),
KEY photo_id (photo_id)
) TYPE=MyISAM;
CREATE;
mysql_query($q);
$nam = sha1_file($file['tmp_name']);
$p = <<<CREATE
insert into $_REQUEST[username] (photo_filename) values ("$name");
CREATE;
mysql_query($p);
?>
the files save with long and unique filenames (eg image8b6f73f2b35b997af7633116bf8f46ab026e0c8d.jpg) - but when i pass the name variable into mysql - it merely saves as "." - it's wildly infuriating! because i know the variable is there but it simply will not carry thought/transmit into the mysql table!
so i'm truly stuck now...! if any of you php gurus can help out with what i'm sure is embarrasingly obvious i'd be so thankful, needless to say, i've clumsily googled this to death to no avail
cheers,
gina
ps - my config is using WAMP server on a win xp machine