madspof Posted June 26, 2007 Share Posted June 26, 2007 i have the variable of the folder name save in $namecookie which belongs to a upload script that is built of js and php and i want to put that variable in the copy($file['tmp_name'],"./$namecookie/".$file['name']); as you can see i think that is correct but when i run the script it does nt upload the file <?php include "../status.php"; $cookie_info = explode("-", $_COOKIE['cookie_info']); $namecookie = $cookie_info[0]; foreach ($_FILES as $file) { copy($file['tmp_name'],"./$namecookie/".$file['name']); } Has anyone any ideas ?> Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/ Share on other sites More sharing options...
trq Posted June 26, 2007 Share Posted June 26, 2007 Have you tried echo'ing $namecookie to see what it contains? Also, you really ought to be using move_uploaded_file() instead of copy(). Why do you want to copy the file? Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283512 Share on other sites More sharing options...
madspof Posted June 27, 2007 Author Share Posted June 27, 2007 i no have this code but i am sill having no look this is a bit advnaced for me and i dont think i am doing th right thing with the echo here: <?php include "../status.php"; $cookie_info = explode("-", $_COOKIE['cookie_info']); $namecookie = $cookie_info[0]; foreach ($_FILES as $file) { copy($file['tmp_name'],"./echo $namecookie/".$file['name']); } ?> Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283834 Share on other sites More sharing options...
JJohnsenDK Posted June 27, 2007 Share Posted June 27, 2007 no you need to put echo like this: foreach ($_FILES as $file) { echo $namecookie; copy($file['tmp_name'],"./echo $namecookie/".$file['name']); } Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283839 Share on other sites More sharing options...
JJohnsenDK Posted June 27, 2007 Share Posted June 27, 2007 woops forgot: and delete this /echo $namecookie/ <?php include "../status.php"; $cookie_info = explode("-", $_COOKIE['cookie_info']); $namecookie = $cookie_info[0]; foreach ($_FILES as $file) { echo $namecookie copy($file['tmp_name'], $file['name']); } ?> Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283841 Share on other sites More sharing options...
JasonLewis Posted June 27, 2007 Share Posted June 27, 2007 uhh. this: foreach ($_FILES as $file) { echo $namecookie; copy($file['tmp_name'],$namecookie.$file['name']); } Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283843 Share on other sites More sharing options...
madspof Posted June 27, 2007 Author Share Posted June 27, 2007 I think im going to use the other function you showed me because i have tried a lot of thing with no luch so i will post bak if i get any furthurer than kyou for the the comments Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283850 Share on other sites More sharing options...
madspof Posted June 27, 2007 Author Share Posted June 27, 2007 if anyone wondered i used this script in the end i moddded it so that it fitted my need and i am gonig to progress onto limmiting the download but here is the basic script <?php include "../status.php"; $cookie_info = explode("-", $_COOKIE['cookie_info']); $namecookie = $cookie_info[0]; $target = "$namecookie/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } ?> Link to comment https://forums.phpfreaks.com/topic/57336-i-cannot-get-this-variable-to-work-in-the-script/#findComment-283922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.