PHP Uploader

Discussion in 'PHP' started by fotoviva, Aug 25, 2008.

Thread Status:
Not open for further replies.
  1. #1
    I want customers to be able to upload photos to my site so I can print them. The files will not actually go onto the site but into a secure area where I can access them and download.

    Clearly this needs to be secure as I don't want the site hacked or misused in any way so what is the best way for this? I don't really know php so something easy to understand would be great! I heard php was best for this thing?

    Thanks :)
     
    fotoviva, Aug 25, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    I'd say your easiest bet would be getting any free image uploader from the internet (as you don't know PHP) - there's always a few free ones around. Then, protect your uploads/ folder (or similar) with .htaccess authentication so only you can access them, even the one that comes with cPanel should work.

    That should get you going :)

    Jay

    P.S. Yes, PHP is the best language for this.
     
    jayshah, Aug 25, 2008 IP
  3. William[ws]

    William[ws] Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I can create this simple script for you at low cost and have it secure etc for you contact me via PM if your interested!
     
    William[ws], Aug 25, 2008 IP
  4. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    php uses $_file to retrieve form data with file path, it uploads to a temp name in a secure area of server. from here you can check file if need be(filetype etc.), before saving it with:
    move_uploaded_file($_FILES['UploadFile']['tmp_name'],$file) where $file is save path.
    If you save to a folder without execute permissions you should have no problem.
    The site I am currently building does exactly what you are asking http://trollnest.com/bragflags/project.php
     
    Sleeping Troll, Aug 25, 2008 IP
  5. fotoviva

    fotoviva Active Member

    Messages:
    265
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    60
    #5
    Oops - page not found!

     
    fotoviva, Aug 26, 2008 IP
  6. nabz245

    nabz245 Well-Known Member

    Messages:
    677
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    110
    #6
    Have the website upload to a directory to your server, which can be prevent public access using a .htaccess file.
    Then, when you want to retrieve the files, simple go into the FTP of the website directory and download the files.

    I hope that helps

    Regards
     
    nabz245, Aug 26, 2008 IP
  7. knarffrank

    knarffrank Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    //create a form in html with a name of ="Upload Image"

    //Use this script
    if($_POST["action"] == "Upload Image")
    {
    echo "<meta http-equiv='refresh' content='0;url=upload.php'>";
    unset($imagename);
    if(!isset($_FILES) && isset($HTTP_POST_FILES))
    $_FILES = $HTTP_POST_FILES;
    if(!isset($_FILES['image_file']))
    $error["image_file"] = "An image was not found.";
    $imagename = basename($_FILES['image_file']['name']);
    if(empty($imagename))
    $error["imagename"] = "The name of the image was not found.";
    if(empty($error))
    {if(empty($numq))
    {if($numall>=5)
    {echo "Limit Exceeded!";}else
    {$newimage = "images/" . $imagename;
    $result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
    $upd= @mysql_query("INSERT INTO up_tb (title,photo,altg,descrip,pid) VALUES ('$imagename','title','EnterTagsHere','DescriptionHere','$pi')"); }
     
    knarffrank, Aug 26, 2008 IP
  8. knarffrank

    knarffrank Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    In case you don't know how to do this in html use this

    <form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
    <p><input type="file" name="image_file" size="20"></p>
    <p><input type="submit" value="Upload Image" name="action"></p>
    </form>

    and the php i posted above.. and there you go..
     
    knarffrank, Aug 26, 2008 IP
  9. William[ws]

    William[ws] Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Job Done. Create person to work for.
     
    William[ws], Sep 5, 2008 IP
  10. XXXWebGURUXXX

    XXXWebGURUXXX Banned

    Messages:
    197
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    If u need php uploader script

    i made 1

    PM me i can give u at cheap rate
     
    XXXWebGURUXXX, Sep 6, 2008 IP
  11. William[ws]

    William[ws] Peon

    Messages:
    47
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #11
    [EDIT]
    Job Done. Great person to work for.
     
    William[ws], Sep 6, 2008 IP
Thread Status:
Not open for further replies.