SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    273
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    simple upload question

    very simple question


    how do i upload a pic gif or jpeg format to a mysql db and then retirve it to be displayed...

    kinda easy for u guys but sorry i am dumb at this.

    do write back

    thanx bye

  2. #2
    SitePoint Zealot Mau's Avatar
    Join Date
    Jan 2006
    Location
    California, USA
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll post a sample code when I get the chance to. (I am a newb but should be able to do it.) lol.
    Need any video services done? PM me
    Watermarking, Thumbnails, Video Content Submission,
    Encoding videos including Flash (.flv).

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2006
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have two questions related to this.
    1. I tried installing this script and it works. However If the file already exists I want it to replace the file.
    Here is my script so far, and it lets me know if the file exists, but then does not replace it.

    The end result is that I want an administrator to upload a pic, and it will replace the picture on a webpage. So..If they name the pic for the index page always..index.jpg, it will replace the index.jpg picture with the new index.jpg picture on the index page.
    2. Would it be better to save the image to a database, and then pull it from the database..by telling it to display the last file added to the database.
    OR.
    Is there a better way..


    <?php
    if ($userfile_size >250000)
    {$msg=$msg."Your uploaded file size is more than 250KB so please reduce the file size and then upload. Visit the help page to know how to reduce the file size.<BR>";
    $file_upload="false";}

    if (!($userfile_type =="image/pjpeg" OR $userfile_type=="image/gif")){$msg=$msg."Your uploaded file must be of JPG or GIF. Other file types are not allowed<BR>";
    $file_upload="false";}

    $add="upload/$userfile_name"; // the path with the file name where the file will be stored, upload is the directory name.

    if (file_exists("upload/" . $_FILES["userfile"]["name"]))
    {
    echo $_FILES["userfile"]["name"] . " already exists. ";
    }


    if(move_uploaded_file ($userfile, $add)){
    // do your coding here to give a thanks message or any other thing.

    }else{echo "Failed to upload file Contact Site admin to fix the problem";}

    ?>


Bookmarks

Posting Permissions

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