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 ?> Quote Link to comment 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? Quote Link to comment 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']); } ?> Quote Link to comment 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']); } Quote Link to comment 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']); } ?> Quote Link to comment 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']); } Quote Link to comment 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 Quote Link to comment 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."; } ?> Quote Link to comment 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.