Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 13 of 13
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How do I let users upload pictures?

    Hi, I have a memberhsip site that each user has their own profile and I would like to make it so that they can upload their pictures onto their profile page. How do I do this? I'm using dreamweaver, thanks!

  • #2
    ubh
    ubh is offline
    Regular Coder ubh's Avatar
    Join Date
    Apr 2008
    Location
    Portland, Oregon U.S.A.
    Posts
    443
    Thanks
    108
    Thanked 15 Times in 14 Posts
    http://www.tizag.com/phpT/fileupload.php

    That would help with getting started in the file upload process. Also upon uploading, you might want to store the path of the images location in the database for this particular user. This way it will pull up the correct photo for the correct user.

    Hope this helps.

  • #3
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    You need a upload html form which will submit the uploaded to a script that then processes the script and that would save the file path to a database. Are you using a database for your members to log into.

    This is the html form
    Code:
    <form enctype="multipart/form-data" action="uploader.php" method="POST">
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
    Choose a file to upload: <input name="uploadedfile" type="file" /><br />
    <input type="submit" value="Upload File" />
    </form>
    then the processing script

    PHP Code:
    $target_path "uploads/";

    $target_path $target_path basename$_FILES['uploadedfile']['name']); 

    if(
    move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
        echo 
    "The file ".  basename$_FILES['uploadedfile']['name']). 
        
    " has been uploaded";
    } else{
        echo 
    "There was an error uploading the file, please try again!";

    Let me know if you are using sql and I'll help you get the script that stores the filename for that user
    You can not say you know how to do something, until you can teach it to someone else.

  • #4
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Quote Originally Posted by ubh View Post
    http://www.tizag.com/phpT/fileupload.php

    That would help with getting started in the file upload process. Also upon uploading, you might want to store the path of the images location in the database for this particular user. This way it will pull up the correct photo for the correct user.

    Hope this helps.
    haha my code came from the same web page lol
    You can not say you know how to do something, until you can teach it to someone else.

  • #5
    Regular Coder
    Join Date
    Mar 2009
    Location
    Troutdale, OR
    Posts
    145
    Thanks
    12
    Thanked 6 Times in 6 Posts
    Here is a good tutorial on file upload. Good luck.

  • #6
    New Coder
    Join Date
    Mar 2009
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks, yes i'm using a database, thanks for your help

  • #7
    New Coder
    Join Date
    Mar 2009
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    now once i have them save the pic to the folder, how do i make the picture come up on their profile page? and for each member?

  • #8
    New Coder
    Join Date
    Mar 2009
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    retrieving photos

    i know how to let users upload photos to my website but how do i make it so that their pictures come up on their member profile page? can i save the images in my database?

  • #9
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Yes that is exactly what you need to do just save the file path to there user table. create a field in the database called FILENAME or something then use an SQL insert to insert the filepath to that field. Do you need help to do this? If so what database are you using?
    You can not say you know how to do something, until you can teach it to someone else.

  • #10
    ubh
    ubh is offline
    Regular Coder ubh's Avatar
    Join Date
    Apr 2008
    Location
    Portland, Oregon U.S.A.
    Posts
    443
    Thanks
    108
    Thanked 15 Times in 14 Posts
    Yes so like timgolding is saying upon the upload process you should save this images absolute path to the database. Then when a user logs on and a call to the database for their information is sent you can retrieve their pictures location.

    Echo it out:
    PHP Code:
    echo '<img src="'.$picture.'" alt="'.$username.' Photo'.'" />'

  • #11
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well i have sql and how would i make the name of the file saved to be a var

  • #12
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how would i make it save with a name that is different than wat i upload with

  • #13
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,519
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Change the target path

    PHP Code:

    $target_path 
    "uploads/";

    $target_path $target_path 'Your_new_filename'
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •