Jump to content

adding a .jpg to a folder


Hooch

Recommended Posts

it would all depend on where the image comes from, but if the user were to upload it as they register (?) you'd need to look into uploading images .. plenty of scripts/tutorials around.If you were copying the image from another location, you'd want to use something like:

<?php  $to_folder = "user_folder";  $file = "image.jpg";  if (!(copy($to_folder,$file))) { echo "Error copying file"; }  else { echo "File successfully copied"; }  ?>

Link to comment
Share on other sites

The second part is correct, thank you. I need a base image to start off with for every user. But it needs to be in their own folder. Thats why I didn't link a static pic. I will give this a try tonight. Much appreciated. Thanks again.

Link to comment
Share on other sites

She's a no go.Here's my snippet of the mkDIR and then the code you made me.

	 $mkDIR  =  ("images/users/".$username);	 mkdir($mkDIR);	 chmod($mkDIR,  0777);  	 $file = "images/bg.jpg"; 	 if ((copy($mkDIR,$file)))	 { echo "File successfully copied"; }		 else 	 { echo "Error copying file"; }

Is never moves that file over.Any ideas?**EDIT I did a little reading here on W3. Would this be a better solution? Quote from W3"move_uploaded_file(file,newloc) Note: This function only works on files uploaded via HTTP POST."is it possible to hide an upload within a form? And have that uploadedfile come from the same server the form is on?

Link to comment
Share on other sites

TaDa!!

	 $mkDIR  =  ("images/users/".$username);	 mkdir($mkDIR);	 chmod($mkDIR,  0777);  	 $file = "images/bg.jpg";	   	 if( copy ($file, 'images/users/' . $username . '/bg.jpg') )	 { echo ""; }		 else	 { echo ""; }

Works like a charm

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...