Hooch Posted January 20, 2007 Share Posted January 20, 2007 I have a usersystem set up that when a user registers,a folder is created in their name. Is it possibleto have a picture (.jgp) placed in that folder automatically?Thank you Hooch Link to comment Share on other sites More sharing options...
MrAdam Posted January 20, 2007 Share Posted January 20, 2007 where will the ".jpg" image come from?but yes it's possible, when you create the folder, create some more code to add the jpg file aswell. Link to comment Share on other sites More sharing options...
Hooch Posted January 20, 2007 Author Share Posted January 20, 2007 I will have the jpg in the folder above all the username folders. Any idea what the code would be? Link to comment Share on other sites More sharing options...
MrAdam Posted January 20, 2007 Share Posted January 20, 2007 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 More sharing options...
Hooch Posted January 20, 2007 Author Share Posted January 20, 2007 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 More sharing options...
Hooch Posted January 21, 2007 Author Share Posted January 21, 2007 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 More sharing options...
justsomeguy Posted January 22, 2007 Share Posted January 22, 2007 No, that's not possible. If the code above is not working, you need to figure out why. Have it print out all error messages and warnings and see what it says. Link to comment Share on other sites More sharing options...
Hooch Posted January 23, 2007 Author Share Posted January 23, 2007 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 More sharing options...
MrAdam Posted January 23, 2007 Share Posted January 23, 2007 if you don't want it to give any output, just put: copy($file, 'images/users/' . $username . '/bg.jpg'); Link to comment Share on other sites More sharing options...
Hooch Posted January 24, 2007 Author Share Posted January 24, 2007 Thank you kindly for your help guys. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now