Jump to content

pass a variable?


koolaid

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/73527-pass-a-variable/
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/73527-pass-a-variable/#findComment-370980
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.