Making a imageuploader website, need some help.

Discussion in 'PHP' started by Jikdor, Jun 30, 2007.

  1. #1
    Im working on website, Im new to PHP, right now when a image is uploaded its placed in "uploads/" and renamed so its 8 random numbers in front of the file name. Now what I want do do is all the spaces in the name gets renamed to a _ and uppercase gets renamed to lower. Also how do I limit file types and size?

    The only thing i could offer in return is maby ad space on the site and/or loads of web space =P

    Post here or add my msn:

    Also what a nice forum i just found :D
     
    Jikdor, Jun 30, 2007 IP
  2. Free Directory

    Free Directory Peon

    Messages:
    89
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    use that way:
    $fname : the original filename, prefixed or not with that 8 numbers
    
    $fname=strtolower($fname);
    $fname=str_replace(" ","_",$fname);
    
    Code (markup):
    and you'll have what you need.
    About file type and size... you can check that in the $_FILE['filename'] :)
    Enjoy
    You can check there the uploaded file size and also the mime type (file type).
    And also checking extension for the original filename will help.
     
    Free Directory, Jun 30, 2007 IP
  3. Jikdor

    Jikdor Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks alot renameing workes fine :)
     
    Jikdor, Jun 30, 2007 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Use my ready script or:

    * rename files to 8 unique random characters (taking out the old name).
    * place that id in the database along with the filesize,orginal name (for download) and hits

    This would keep you from being hacked.

    Peace,
     
    Barti1987, Jun 30, 2007 IP
  5. Jikdor

    Jikdor Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ill try it out :)
     
    Jikdor, Jun 30, 2007 IP
  6. Jikdor

    Jikdor Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    How do i get the width and high and make them to varibales....?

    When echoing out the link for html, how do i siplay the " as normal...

    <img src="http://www.mysite.com/uploads/image.jpg" width="500" height="500" />

    So how would i do this if the imagename is: $new_file_name hight: $hight and width: $width
     
    Jikdor, Jul 1, 2007 IP
  7. jalte

    jalte Peon

    Messages:
    51
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    maybe php 'getimagesize' function is the one you need.
     
    jalte, Jul 2, 2007 IP