Adblock breaks this site

Image Hosting.

Discussion in 'Web Programming' started by Synful, Aug 6, 2012.

  1. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Im looking for a simple image hosting software,

    Im new to websites ect and looking for something very basic where people can Upload an image from the computer to there gallery and then from that gallery post it on forums ect.
     
  2. iJava

    iJava .Previously known as RSGoldRush
    $200 USD Donor New

    Joined:
    Nov 21, 2011
    Posts:
    1,197
    Referrals:
    11
    Sythe Gold:
    485
    Discord Unique ID:
    220055593568829441
    Image Hosting.

    Have you tried Google?
     
  3. DMR

    DMR Grand Master

    Joined:
    Jun 27, 2011
    Posts:
    2,129
    Referrals:
    0
    Sythe Gold:
    15
    Discord Unique ID:
    285670177029226497
    Discord Username:
    dmr
    Image Hosting.

    There so much. You should have google'd it.

    tinypic
    photobucket

    to name a few.
     
  4. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    You guys shouldn't post in the web programming section if you don't no what a script is...
     
  5. Dial

    Dial Experienced Web Developer
    $200 USD Donor New Pirate PHP Programmers

    Joined:
    Jul 12, 2010
    Posts:
    5,739
    Referrals:
    32
    Sythe Gold:
    126
    Sythe's 10th Anniversary Two Factor Authentication User MushyMuncher Member of the Month Winner Easter 2015
    Image Hosting.

    Here's a very simple script taken from my old website. Feel free to edit it how you want, and ask any questions here if you need help using/understanding it.

    Put this form wherever you want it.

    Code:
    <form action="pictureupload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="upload" value="" required="required" />
    <input type="submit" value="" />
    </form>
    
    Make a file called pictureupload.php and put this in it.

    PHP:
                        $target_path "/pathtoupload/";
                        
    //die($target_path);
                        //Owner: read/write, all else fail
                        
    chmod($target_path0777);
                        
    $error false;
                        
    //size check
                        
    if($_FILES['upload']['size'] > 500000000)
                        {
                            echo 
    '<META http-equiv="refresh" content="0; URL=errorpage.php">';
                        }
                        
                        
    $safe_extensions = array(
                            
    '.jpg',
                            
    '.jpeg',
                            
    '.png',
                            
    '.gif');
                        
                        
    //random name
                        
    $old_name $_FILES['upload']['name'];
                        
    $new_name md5(time());
                        
                        
    $ext stristr($old_name'.');
                        
                        if(!
    in_array($ext$safe_extensions))
                        {
                            echo 
    '<META http-equiv="refresh" content="0; URL=errorpage.php">';
                        }
                        
                        
    $target_path $target_path $new_name.$ext
                        
                        
                        if(!
    $error && move_uploaded_file($_FILES['upload']['tmp_name'], $target_path)) {

                            echo 
    '<META http-equiv="refresh" content="0; URL=successpage.php">'; }
    This was back a long time ago though, and echoing meta refresh isn't really good practice. You should look up how to use PHP header redirects and use those instead in those places.

    Edit:

    So you should replace any of this:

    Code:
    echo '<META http-equiv="refresh" content="0; URL=pagenamehere.php">';
    With this:

    PHP:
    header('Location: pagenamehere.php');
     
  6. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Simple and somewhat flawed unfortunately, but usable.

    I'll take a crack at it, what is your web host like? Free/shared or VPS?
     
  7. Dial

    Dial Experienced Web Developer
    $200 USD Donor New Pirate PHP Programmers

    Joined:
    Jul 12, 2010
    Posts:
    5,739
    Referrals:
    32
    Sythe Gold:
    126
    Sythe's 10th Anniversary Two Factor Authentication User MushyMuncher Member of the Month Winner Easter 2015
    Image Hosting.

    Like I said, it was pretty old, and probably from a tutorial actually. What was flawed about it though, if you don't mind me asking?
     
  8. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Umm, Hostgator.com is where I bought it lol.


    Yeah, Its good when people post stuff like you did I find it easy to learn stuff when I have it in front of me. So thanks very much =)
     
  9. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    PHP:
    chmod($target_path0777);
    You allow files to be executed, 664 would be a more appropriate permission for a file that is simply going to be read.

    PHP:
    $safe_extensions = array();
    You don't check the mime type being sent, only the extension. You could hide a script renamed as .jpg and run it directly (Unless you did a FORCED DOWNLOAD).



    Just some security issues to be mindful of.
     
  10. Dial

    Dial Experienced Web Developer
    $200 USD Donor New Pirate PHP Programmers

    Joined:
    Jul 12, 2010
    Posts:
    5,739
    Referrals:
    32
    Sythe Gold:
    126
    Sythe's 10th Anniversary Two Factor Authentication User MushyMuncher Member of the Month Winner Easter 2015
    Image Hosting.

    Ah, thanks for that. I didn't really think of it.

    Hopefully you can write a new one for Synful then.
     
  11. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Hi Jazz if you could right me a very simple script that allows me to upload images then see the image link that would be great Im willing to pay if you could help me with this =)

    Thanks very much.
     
  12. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Just creating a nice script for you :)
    I'll reply back when it's done
     
  13. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Ok thank you very much.
     
  14. matt_sells

    matt_sells Member

    Joined:
    Nov 28, 2011
    Posts:
    78
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Just an idea for you, since it seems that your programming knowledge is limited, use a cms for your site. not detracting from what jazz is doing, but you'll be able to find a "plugin" that will your visitors to upload images, but with a cms you will also be able to do the things you probably cant atm, e.g. seo, allow for people signing up, for private access to galleries, etc etc etc. So for something that would cost you a few hundred quid, you could pretty much do yourself in a day for free.

    As for a cms to use, if you wish to, I'm biased and always say wordpress, because it suits me best but joomla, drupal etc would work very well for this type of site(presuming you want to spam it out with ads)

    Also with "some" experience in this type of website, make sure you have a disclaimer when people upload stuff, otherwise copyright is your problem = bad thing.
     
  15. novice

    novice Active Member

    Joined:
    Jun 21, 2008
    Posts:
    111
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Is it shared, VPS or dedicated? Hostgator doesn't allow image hosting scripts on shared hosting.

    http://www.hostgator.com/tos/tos.php
     
  16. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

  17. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Here's what I have so far: Upload Gallery

    Still needs some work on
    • user detection
    • gallery
    • error catching on display pages
     
  18. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    thanks jazz looks really really good so far =)
     
  19. Jazz00006

    Jazz00006 Apprentice
    Visual Basic Programmers

    Joined:
    Aug 26, 2005
    Posts:
    807
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    Oh boy, here we go. Hopefully we can keep this thread civil from now on? (Both sides please)



    I might not be able make much progress today with work and all, but the next item on my agenda is the gallery.

    Then I'll clean up the code and throw in the last bits of error checking.



    Questions, comments or complaints so far?
     
  20. Synful

    Synful Dragon Slayer
    Banned

    Joined:
    May 24, 2012
    Posts:
    441
    Referrals:
    0
    Sythe Gold:
    0
    Image Hosting.

    its perfect man, its exactly what Im after. Thanks very very much. =)
     
< Dreamweaver | Enjin Professional Needed - Minecraft site >


 
 
Adblock breaks this site