flashwiz Posted July 9, 2009 Share Posted July 9, 2009 Hi guys, I have this script I am using to save images to a server, the code is being triggered by a flash app. I would like to be able to send a variable via query string from flash and have php use it for the directory name. Here is my current script...thanx for the help: <?php // if directory doesn't exist make it if(!is_dir("./files")) mkdir("./files", 0755); $moveToDir = 'files/'; foreach ($_FILES as $fieldName => $file) { $uploadFileName = $file['name']; move_uploaded_file($file['tmp_name'], $moveToDir.$uploadFileName); chmod("./files/".$file['tmp_name'], 0777); } ?> and this is what I am sending: "multi.php?folder=someValue" Link to comment https://forums.phpfreaks.com/topic/165299-php-syntax-question/ Share on other sites More sharing options...
p2grace Posted July 9, 2009 Share Posted July 9, 2009 Try this: <?php // Folder specified in url $folder = $_GET['folder']; // place this folder wherever you need it in the script, but this is how you reference it. // if directory doesn't exist make it if(!is_dir("./files")) mkdir("./files", 0755); $moveToDir = 'files/'; foreach ($_FILES as $fieldName => $file) { $uploadFileName = $file['name']; move_uploaded_file($file['tmp_name'], $moveToDir.$uploadFileName); chmod("./files/".$file['tmp_name'], 0777); } ?> Link to comment https://forums.phpfreaks.com/topic/165299-php-syntax-question/#findComment-871740 Share on other sites More sharing options...
flashwiz Posted July 9, 2009 Author Share Posted July 9, 2009 Thanx for the reply, my issue is how to get the variable to replace the name "files" on these lines: if(!is_dir("./files")) mkdir("./files", 0755); $moveToDir = 'files/'; chmod("./files/".$file['tmp_name'], 0777); Link to comment https://forums.phpfreaks.com/topic/165299-php-syntax-question/#findComment-871757 Share on other sites More sharing options...
Q Posted July 9, 2009 Share Posted July 9, 2009 Try this: if(!is_dir("./" . $folder)) mkdir("./" . $folder, 0755); $moveToDir = $folder . "/"; chmod($folder . "/" .$file['tmp_name'], 0777); Link to comment https://forums.phpfreaks.com/topic/165299-php-syntax-question/#findComment-871761 Share on other sites More sharing options...
flashwiz Posted July 9, 2009 Author Share Posted July 9, 2009 Great! All I had to do is changed the last line you posted to this and it worked: chmod($folder . "/" .$content, 0777); Thanx dude Link to comment https://forums.phpfreaks.com/topic/165299-php-syntax-question/#findComment-871769 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.