SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Images Uploading!

    i need a very basic script that allows people to upload a image then tell them what the link is..... EG www.gamesxposed.com/upload/
    i try hotscripts but all they have is really advance scripts and i only need a small one like this one www.gamesxposed.com/upload/

  2. #2
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very simple?

    simple.php
    HTML Code:
    <form name="simple_image_upload" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
    <input type="file" name="image">
    <input type="submit" name="submit_value">
    </form>
    simple.php
    PHP Code:
    if (isset($_POST['submit_value']) {
       
    move_uploaded_file($_FILES['image']['tmp_name'], '/path/to/images/dir/' $_FILES['image']['name']);
    echo <<<HTML
       The image is at:
       <a href="www.mywebserver.com/images/dir/
    $_FILES[image][name]">www.mywebserver.com/images/dir/$_FILES[image][name]</a>
    HTML;

    This is untested, and has very little error checking, but should provide a good starting point

    Edit:


    Added enctype as per excellent suggestions
    Last edited by lieut_data; Oct 1, 2003 at 18:35.
    My name is Steve, and I'm a super-villian.

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is that the whole code? if it is then thats crazy

  4. #4
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sniper12p
    is that the whole code? if it is then thats crazy
    Crazy as in good?

    or crazy as in "That'll never work, it's-- it's too short!"?

    That code *should* work, but you're right -- there's no fancy GUI, no style-sheets, no error checking for files that are 2mb large, no checking to see if the file overwrites another, already existing file -- etc...

    But, it *is* simple
    My name is Steve, and I'm a super-villian.

  5. #5
    SitePoint Member
    Join Date
    Sep 2003
    Location
    canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    crazy as good and me thinkign im too stuped to figure that out myself lol

  6. #6
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sniper12p
    crazy as good and me thinkign im too stuped to figure that out myself lol
    Haha! Don't berate yourself!

    PHP continues to astound me with it's overall simplicity, yet incredible power!!!
    My name is Steve, and I'm a super-villian.

  7. #7
    SitePoint Member
    Join Date
    Sep 2003
    Location
    canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    of course me being stuped i cant get it LOL!!!!!! can you write me the script then you tell me what to change?

  8. #8
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    isn't neccisary to have enctype="multipart/form-data" in the form tag? as explained here: http://is2.php.net/features.file-upload
    - website

  9. #9
    SitePoint Member
    Join Date
    Sep 2003
    Location
    canada
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i dont get it.........could i just download a script from a site? do yuo know any>

  10. #10
    Free your mind Toly's Avatar
    Join Date
    Sep 2001
    Location
    Panama
    Posts
    2,181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by website
    isn't neccisary to have enctype="multipart/form-data" in the form tag? as explained here: http://is2.php.net/features.file-upload
    Yes it is.
    Community Guidelines | Community FAQ

    "He that is kind is free, though he is a slave;
    he that is evil is a slave, though he be a king." - St. Augustine


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
  •