koolaid Posted October 16, 2007 Share Posted October 16, 2007 Thank you for even reading this and trying to help me. I have two php scripts. I need to communicate with each other. I am an Action Script developer so i AM php RETARDED. This is my first one that takes my flash variables creates the right directory then write a text doc to it. Next the user is uploading a file. I want that image file to save to the same directory as the text doc wrote too. The only copmplicted part of this is that the user names the directory ($_POST["clientsName"]) so when i run my upload php i need to get the directory name. HERE IS THE FIRST PART <?php ///my flash variables $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; $folder = "./files/".$_POST["clientsName"]."/"; if(!is_dir($folder)) mkdir($folder, 0755); $mode = file_exists($folder.'user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen($folder.'user_input.txt',$mode); // open file foreach($_POST as $K => $V) { fwrite($fp,"$K = $V\r\n"); // dump the contents of the $_POST array to the file } fclose($fp); ?> HERE IS MY UPLOAD PHP <?php //create the directory if doesn't exists (should have write permissons) if(!is_dir("./files")) mkdir("./files", 0755); //move the uploaded file move_uploaded_file($_FILES['Filedata']['tmp_name'], "./files/".$_FILES['Filedata']['name']); chmod("./files/".$_FILES['Filedata']['name'], 0777); ?> Thanks again guys Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/ Share on other sites More sharing options...
mattal999 Posted October 16, 2007 Share Posted October 16, 2007 im sorry, i dont quite understand, what exactly is the problem here? Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-370957 Share on other sites More sharing options...
koolaid Posted October 16, 2007 Author Share Posted October 16, 2007 Both the scripts work. I just need to pass the var $folder from the first script to the second script so that when the user uploads the photo it saves to the same directory as the text doc wrote to Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-370962 Share on other sites More sharing options...
mattal999 Posted October 16, 2007 Share Posted October 16, 2007 so make it all 1 script: <?php ///my flash variables $_POST["repsName"] . $_POST["clientsName"]. $_POST["clientsPhone"]. $_POST["clientsUrl"]. $_POST["shortDescroption"]. $_POST["longDescription"]; $folder = "./files/".$_POST["clientsName"]."/"; if(!is_dir($folder)) mkdir($folder, 0755); $mode = file_exists($folder.'user_input.txt')?'a':'w'; // append if file exists otherwise create it $fp = fopen($folder.'user_input.txt',$mode); // open file foreach($_POST as $K => $V) { fwrite($fp,"$K = $V\r\n"); // dump the contents of the $_POST array to the file } fclose($fp); //create the directory if doesn't exists (should have write permissons) //move the uploaded file move_uploaded_file($_FILES['Filedata']['tmp_name'], $folder); chmod($folder."".$_FILES['Filedata']['name'], 0777); ?> i havent tested it (duh) but i think it should work... Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-370980 Share on other sites More sharing options...
koolaid Posted October 16, 2007 Author Share Posted October 16, 2007 I can make it one script even though i call on the at different times? Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-370987 Share on other sites More sharing options...
koolaid Posted October 16, 2007 Author Share Posted October 16, 2007 I have to call on them at different times because of the way the flash is structured. What about sessions? A buddy of mine said i might be able to accomplish this with sessions. Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-371043 Share on other sites More sharing options...
koolaid Posted October 17, 2007 Author Share Posted October 17, 2007 ??? Quote Link to comment https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-371505 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.