angryjohnny Posted June 10, 2008 Share Posted June 10, 2008 I have a simple PHP script that lets the user upload images to a directory on my server. $uploaddir = 'images/'; $uploadfile = $uploaddir . basename($_FILES['userfile']['name']); if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { echo "File is valid, and was successfully uploaded."; } Which works fine. This scipt as you can see will upload an image to a directory, path: images/imagename.jpg. What I'm trying to do is set a variable for "images/" called "$folder". So depending what link the user clicked on to get to the upload page, this variable changes allowing images to be uploaded to different directories. So my first thought was to simple change this line to get it working: $uploaddir = 'images/'; to $uploaddir = $folder; The variable $folder is being read properly but when I submit the form to upload the file it leaves out the $folder and just writes the image name uploading it to the same directory the file is in. I have tried 100 different ways to get this to work. I have found a way to get it to work but its not very sufficient. Can someone please help. Thank you John Link to comment https://forums.phpfreaks.com/topic/109628-problem-uploading-images-to-different-directories/ Share on other sites More sharing options...
rarebit Posted June 10, 2008 Share Posted June 10, 2008 I know it sounds... print "folder: ".$folder."<br>"; ... just to check Link to comment https://forums.phpfreaks.com/topic/109628-problem-uploading-images-to-different-directories/#findComment-562468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.