Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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