Jump to content

Upload images to folders


unplugged_web

Recommended Posts

I'm trying to get a file to upload to a folder depending on which is different depending on what option the user has selected. The folder name is sent in the $designer variable but I'm not sure how to add it to code I've got.

$pic  = $_FILES['photo']['name'];$target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/' . basename( $_FILES['photo']['name']);$temp_name = $_FILES['photo']['tmp_name'];$type = $_FILES["photo"]["type"];

I tried adding it to the target line so that it was like this:

$target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/$designer/' . basename( $_FILES['photo']['name']);

But all I got was an error saying that the folder wasn't there. If I try adding it without the $designer variable then it submits okay but I do need it to be in a different folder depending on the option selected.

Thanks

Link to comment
Share on other sites

try using double quotes so $designer is interpolated inside the string, or else concatonate all the parts together.

$target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/' . $designer . basename($_FILES['photo']['name]);
Edited by thescientist
Link to comment
Share on other sites

  • 2 weeks later...

Sorry I think I made a mistake in the original post, the target needs to be like this:

 

$target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/designer/' . basename( $_FILES['photo']['name']);

 

I've tried doing it like this but it doesn't work:

 

$target = '/home/linweb22/f/domain.com/user/htdocs/new/designers/images/$designer/' . basename( $_FILES['photo']['name']);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...