EKsparky Posted February 28, 2008 Share Posted February 28, 2008 I've got a basic upload script The idea is that you upload a picture to an album So i keep the script in galleries dir now in that dir there are other folders each of these is an album examlpe folder1 folder2 folder3 now my script works fine if i just upload to galleries but when i try to add an album var to the path it goes wrong It still up loads the picture but places it in galleries folder and rename the picture Example i upload ME.jpg it will appear in the galleries folder as folder1ME.jpg Heres my code <h3>File Upload</h3> Select a file to upload:<br> <form action="uploader.php" method="post" enctype="multipart/form-data"> <input type="file" name="file" size=50> <br> Choose album: <input name="choose_album" type="text"><br> <input type="submit" value="Upload File"><br> </form> <?php $A_path = $_POST['choose_album']; if($_FILES['file']['name'] !="") { copy ($_FILES['file']['tmp_name'], "galleries/$A_path".$_FILES['file']['name']) or die("Could not copy file"); } else { die("No file specified"); } ?> <html> <head> <title>Upload complete</title> </head> <body> <h3>File upload succeeded...</h3> <ul> <li>Sent: <?php echo $_FILES['file']['name']; ?> <li>Size: <?php echo $_FILES['file']['size']; ?> bytes <li>Type: <?php echo $_FILES['file']['type']; ?> </ul> <?php echo ''.$A_path.''; ?> <a href="<?php echo 'galleries/$A_path'.$_FILES['file']['name']; ?>">Click here to view file</a> </body> </html> Now echo $A_path near the bottom will infact echo album name so i was thinking maybe i am missing some punctuation in the 2 lines with the path Thanks Quote Link to comment Share on other sites More sharing options...
EKsparky Posted February 29, 2008 Author Share Posted February 29, 2008 BUMP Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 29, 2008 Share Posted February 29, 2008 Add the slash maybe? copy ($_FILES['file']['tmp_name'], "galleries/$A_path/".$_FILES['file']['name']) or die("Could not copy file"); Quote Link to comment Share on other sites More sharing options...
EKsparky Posted February 29, 2008 Author Share Posted February 29, 2008 Thanks for reply I did try that before and after and together Tried again just to be sure and no luck :'( Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 29, 2008 Share Posted February 29, 2008 what happens if you replace $A_path with folder1/ ? Quote Link to comment Share on other sites More sharing options...
EKsparky Posted February 29, 2008 Author Share Posted February 29, 2008 Does the same thing just uploads to galleries and renames pic folder1me.jpg or folder1myimagename.jpg even does same thing if i add full path /var/www/html/mysites/public_html/photos/galleries Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 29, 2008 Share Posted February 29, 2008 Did you replace it like so? copy ($_FILES['file']['tmp_name'], "galleries/folder1/".$_FILES['file']['name']) or die("Could not copy file"); Quote Link to comment Share on other sites More sharing options...
EKsparky Posted February 29, 2008 Author Share Posted February 29, 2008 yes Quote Link to comment Share on other sites More sharing options...
deansatch Posted February 29, 2008 Share Posted February 29, 2008 Just out of curiosity, would move_uploaded_file() not be a better function for what you are trying to do? 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.