fcOnTheWeb Logo Web technologies, made easy.

fcOnTheWeb Red DotHosting images on The Internet

The Internet currently has many image hosting services available that are free to use. Image hosting services such as ImageShack, Photobucket, and xs.to to name just a few.

Here at fcOnTheWeb, we have decided to launch our own image hosting service.

What happens is you, the user, uploads an image through the form. We give that image a unique name then move it to the appropriate folder. Once there, we give you back the URL to the image, with its new name.

We use a unique name so that if images with common names are uploaded (my_cat.jpg for example) the names do not clash and images do not get overwritten.

We are using a using a unique system similar to the one we used in our short URL project. We generate a random hash, then check in a database to ensure it has not been used before. If it has, we generate a new random hash and start again. When we confirm that it is a unique name, we add it to the database then rename the image with it.

So, how is it done? Let's find out.

A normal HTML form is used to allow the user to select their image. There are a couple of things to be aware of. Firstly, the enctype has to be multipart/form-data (sometimes for forms this does not matter, but it does in this case). And the type of input we use to allow the user to select a file is the file type. So the form looks something like this:

<form name="your_form_name" method="POST" action="your_submission_page.php" enctype="multipart/form-data">

Select a file to upload... <input type="file" size="60" name="your_field_name" />

<input type="submit" value="Upload file NOW!" />

</form>

Now lets take a look a the page our form submits to. We need to first check that there is a file being uploaded before we do anything else.

if (isset($_FILES["your_field_name"]["tmp_name"])) {

...

}

Once we know an image is being uploaded, we want to make sure the file is in fact an image and not something else.

We use getimagesize which will return false if the file is not an image, or an array of its properties if it is an image. We can then check this array to see if the image is of the type we will allow.

$get_image_size_result = getimagesize($_FILES["uploaded_file"]["tmp_name"]);

if ($get_image_size_result["mime"] == "image/jpeg" || $get_image_size_result["mime"] == "image/jpg"

|| $get_image_size_result["mime"] == "image/gif" || $get_image_size_result["mime"] == "image/png") {

...

}

Once we have determined that the file is indeed a valid image format, we need to get a random name for it. We use the same get_random_hash() as we used earlier. It has 21,083,232,519,264,920,575 possible combinations, so suits our needs.

$target_path_file = get_image_hash();

...

function get_image_hash() {

$hash_is_verified = false;

while ($hash_is_verified == false) {

$random_hash = get_random_hash();

if (check_random_image_hash_in_db($random_hash)) {

} else {

$hash_is_verified = true;

}

}

return $random_hash;

}

function get_random_hash() {

$random_hash = "";

$letters_array = array("a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "m", "n", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z");

for ($i = 0; $i < 7; $i = $i + 1) {

$random_hash = $random_hash . $letters_array[array_rand($letters_array)];

}

return $random_hash;

}

Now we have our new name, we just need to move the file to its new location with its new name.

if (move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], $_SERVER["DOCUMENT_ROOT"] .

substr(basename($_FILES["uploaded_file"]["name"]), strrpos(basename($_FILES["uploaded_file"]["name"]), ".")))) {

echo "Image uploaded.";

} else {

echo "There has been an error";

}

And there you have it. An image hosting service, as easy as that.

We will be running this service for a while and monitoring its use. If it is abused or using too much bandwidth, it will be stopped.

Also, images uploaded to fcOnTheWeb are subject to removal, without warning, if we see fit.

Use it wisely, and enjoy.

ferrari_chris

rabo (http://flashden.blogspot.com/) says:

2012-02-29 04:51:39

good artical

__________

oakley sunglasses cheap (http://www.oakleysunglassescheap.us.com/) says:

2014-07-12 02:07:32

http://www.oakleysunglassescheap.us.com/ oakley sunglasses

cheap
http://www.coachoutletstoreonlineco.com/ coach factory outlet
http://www.abercrombie-andfitch.com/ abercrombie and fitch
http://www.michaelkors-outletsonline.com/ michael kors outlet
http://www.oakley-sunglassesoutlet.com/ oakley sunglasses

outlet
http://www.tory-burchoutlet.com/ tory burch outlet
http://www.abercrombieandfitchstore.com/ abercrombie & fitch
http://www.rayban--sunglasses.com/ ray ban sunglasses
http://www.fit-flops.co.uk/ fitflops
http://www.coachoutlet-factoryonline.com/ coach factory outlet
http://www.toryburch-shoes.com/ tory burch shoes
http://www.coachstoreonline.org/ coach outlet store online
http://www.coachfactory-outletinc.com/ coach factory outlet
http://www.cheapraybansunglasses.us/ cheap ray ban sunglasses
http://www.valentino.us.com/ valentino
http://www.fitfloponline.co.uk/ fitflop uk
http://www.coach-outletinc.com/ coach outlet
http://www.coachoutlet-factorystore.com/ coach outlet store

online
http://www.airjordan.us.com/ air jordan
http://www.timberlandshoesus.com/ timberland shoes
http://www.michaelkorsoutlet-online.us/ michael kors outlet
http://www.coachfactoryoutletnew.com/ coach factory outlet
http://www.coach-factoryoutletinc.com/ coach factory outlet
http://www.truereligionbrandjeans.us.com/ true religion outlet
http://www.truereligionjeans.us.com/ true religion jeans
http://www.coach--handbags.com/ coach outlet online
http://www.louisvuitton--outlet.us/ louis vuitton outlet
http://www.timberland--shoes.com/ timberland boots
http://www.isabelmarantshoes.us.com/ isabel marant shoes
http://www.coachoutletonline-factory.com/ coach outlet online
http://www.michaelkorsoutlet-online.net/ michael kors purses
http://www.louisvuitton-handbag.us/ louis vuitton handbags
http://www.coach-outletstoreonline.com/ coach outlet store

online
http://www.true-religion-jeans.com/ true religion jeans
http://www.coach-outletfactoryonline.com/ coach factory outlet

online
http://www.officialcoachfactoryoutlet.com/ coach factory outlet
http://www.louisvuitton-outlet.org/ louis vuitton outlet
http://www.coach-factoryoutlets.com/ coach factory outlet
http://www.coach-outletonline.us/ coach outlet online
http://www.michaelkorsoutletonlinestore.us/ michael kors outlet
http://www.michaelkorsoutletstoresco.com/ michael kors outlet

store
http://www.tiffanysjewelry-co.com/ tiffany and co jewelry
http://www.celineoutlet-online.com/ celine outlet
http://www.cheap-toms.net/ toms shoes
http://www.celine-handbags.com/ celine handbags
http://www.toms--shoes.us/ toms outlet
http://www.fitflopsandalssale.com/ fitflops
http://www.fitflopusaonline.com/ fitflop outlet
http://www.prada-handbag.com/ prada handbags
http://www.tiffanyandcoinc.com/ tiffany jewelry
http://www.prada-outlet.org/ prada outlet
http://www.michael-korsoutletinc.com/ michael kors
http://www.marcjacobs.us.com/ marc jacobs
http://www.supra.us.com/ supra shoes
http://www.ralphlauren.us.com/ polo ralph lauren
http://www.tiffanyjewelry.us.com/ tiffany jewelry
http://www.shoestoms.net/ toms shoes

__________

POLO says:

2014-08-04 02:48:56

http://www.superbagsmarket.com/ Super Bags Market
http://www.nike-jordanshoes.com/ Nike Jordan Shoes
http://www.thebeatsbydre.net/ Beats By Dre Outlet
http://www.michaelusakors.com/ Michael Kors Outlet Online
http://www.polo-tshirts.com/ Ralph Polo Outlet Online
http://www.northsclearance.com/ North Clearace Outlet
http://www.polo-ralphlaurenonline.com/ Ralph Polo Outlet
http://www.guccishoesuk-2014.net/ Gucci Shoes Outlet
http://www.michaelkorsstates.com/ Michael Kors Outlet
http://www.polooutlet-store.com/ Polo Outlet Store
http://www.ralph-laurenhome.com/ Ralph Lauren UK
http://www.marcjacobsonsale.com/ Marc Jacobs On Sale
http://www.mcmworldwides.com/ MCM Outlet
http://www.salongchamppairs.com/ Sac Longchamp Pairs
http://www.canada-gooser.com/ Canada Goose Outlet
http://www.burberrybags2014.com/ Burberry Outlet
http://www.michaelkors.so/ Michael Kors Outlet
http://www.oakley-sunglassfactory.com/ Oakley Sunglaases Factory
http://www.north-faceoutlet.us.com/ North Face Outlet Online
http://www.moncler-clearance.com/ Moncler Clearance
http://www.woolrich-clearance.com/ Woolrich Clearance
http://www.barbour-jacketsoutlet.com/ Barbour Jackets Outlet Online
http://www.moncler-jacketsoutletonline.com/ Moncler Jackets Outlet Online
http://www.monsterbeatsbydres.net/ Monster Beats Outlet
http://www.louis-vuittonblackfriday.com/ Louis Vuitton Outlet
http://www.lv-guccishoesfactory.com/ Louis Vuitton Factory
http://www.mcmoutlet-jp.com/ MCM 店铺
http://www.cheapdiscountoutlet.com/ Discount Clothes Sale
http://www.michael-korsfactoryonline.com/ Michael Kors Factory Online
http://www.coach-factoryoutlets.net/ Coach Factory Outlet
http://www.coach-blackfriday.net/ Coach Black Friday
http://www.coach-storeoutletonline.com/ Coach Store Outlet Online
http://www.coach-factoryoutletonlines.com/ Coach Factory Outlet Online
http://www.coachcoachoutlet.net/ Coach Outlet
http://www.coach-factory.net/ Coach Factory
http://www.coach-pursesoutlet.net/ Coach Purses Outlet Online
http://www.coach-outletonline.net/ Coach Outlet USA
http://www.mksfactoryoutlet.com/ Michael Kors Factory Outlet
http://www.zxcoachoutlet.com/ Coach Outlet Online USA
http://www.mischristmas.com/ Coach Factory Outlet Online
http://www.misblackfriday.com/ Black Friday
http://www.newoutletonlinemall.com/ Coach Purses Outlet Online
http://www.clickmichaelkors.com/ Michael Kors USA
http://www.cmichaelkorsoutlet.com/ Michael Kors Outlet USA
http://www.ralphlaurenepolo.com/ Ralph Lauren Polo

__________

hollister clothing store (http://www.rayban--sunglass.com/) says:

2014-08-05 02:24:20

http://www.rayban--sunglass.com/ ray ban sunglasses
http://www.customscopyright.com/ coach factory outlet
http://www.hollisterclothing-store.com/ hollister clothing store
http://www.michael--korsoutletonline.com/ michael kors outlet online
http://www.oakley--sunglass.com/ oakley sunglasses cheap
http://www.saclancelfrance.com/ sac lancel
http://www.katespade--outlet.com/ kate spade outlet
http://www.katespadeoutlet-online.com/ kate spade outlet online
http://www.katespade-online.com/ kate spade online
http://www.coachoutlet-onlinestore.com/ coach factory outlet
http://www.abercrombie-andfitch.com/ abercrombie and fitch
http://www.michaelkors-outletsonline.com/ michael kors outlet
http://www.sacportefeuille.com/ sac portefeuille
http://www.oakley-sunglassesoutlet.com/ oakley sunglasses outlet
http://www.michael--korsoutlet.com/ michael kors outlet
http://www.toryburch-outlet-online.com/ tory burch outlet online
http://www.abercrombieandfitchstore.com/ abercrombie & fitch
http://www.fit-flops.co.uk/ fitflops
http://www.coachoutlet-onlinefactory.com/ coach outlet online
http://www.coachfactoryoutlet-bag.com/ coach factory outlet
http://www.tory-burchshoes.com/ tory burch shoes
http://www.coachfactoryoutletclearance.com/ coach factory outlet
http://www.raybansunglasses-cheap.com/ cheap ray ban sunglasses
http://www.valentino.us.com/ valentino
http://www.fitfloponline.co.uk/ fitflop uk
http://www.coach-outletonlinefactory.com/ coach outlet
http://www.coachoutlet-factorystore.com/ coach outlet store online
http://www.air--jordans.com/ air jordan
http://www.timberlandshoesus.com/ timberland shoes
http://www.michaelkors--handbags.com/ michael kors handbags
http://www.coachfactoryoutletnew.com/ coach factory outlet
http://www.coachfactory-onlineoutlet.com/ coach factory outlet
http://www.truereligionbrandjeans.us.com/ true religion outlet
http://www.truereligionjeans.us.com/ true religion jeans
http://www.coach--handbags.com/ coach outlet online
http://www.louisvuitton--outlet.us/ louis vuitton outlet
http://www.timberland--shoes.com/ timberland boots
http://www.isabelmarantshoes.us.com/ isabel marant shoes
http://www.coachoutletonline-factory.com/ coach outlet online
http://www.michael-korsonlineoutlet.com/ michael kors outlet online
http://www.louisvuitton-handbag.us/ louis vuitton handbags
http://www.coach-outletstoreonline.com/ coach outlet store online
http://www.true-religion-jeans.com/ true religion jeans
http://www.coach-outletfactoryonline.com/ coach factory outlet online
http://www.coachfactoryoutlet-official.com/ coach factory outlet
http://www.louis-vuittonoutlets.com/ louis vuitton outlet
http://www.officialcoachonlinefactorysale.com/ official coach factory outlet
http://www.coachoutlet-storefactory.com/ coach outlet online
http://www.michael-korsoutletsonline.com/ michael kors outlet
http://www.tiffanysjewelry-co.com/ tiffany and co jewelry
http://www.celineoutlet-online.com/ celine outlet
http://www.celine-handbags.com/ celine handbags
http://www.toms--shoes.us/ toms shoes
http://www.fitflopsandalssale.com/ fitflops
http://www.fitflopusaonline.com/ fitflop outlet
http://www.prada-handbag.com/ prada handbags
http://www.tiffanyandcoinc.com/ tiffany jewelry
http://www.prada-outlets.com/ prada outlet
http://www.michael-korsoutletinc.com/ michael kors
http://www.marcjacobs.us.com/ marc jacobs
http://www.supra.us.com/ supra shoes
http://www.ralphlaurenpolo-inc.com/ polo ralph lauren
http://www.tiffanyjewelry.us.com/ tiffany jewelry

__________

victoria secret uk (http://www.horsehackers.com) says:

2014-11-13 20:16:21

So have at it, and enjoy!

__________

http://www.skype-credit-gratuit.fr (http://www.skype-credit-gratuit.fr) says:

2014-11-13 20:34:17

So have at it, and enjoy!

__________

Haroplaifs (http://cheapvia25mg.com) says:

2017-10-15 09:07:39

Does Amoxicillin Ever Expire Acheter Cialis Paiement Cheque <a href=http://howtogetvia.com>generic viagra</a> Priligy Auf Kassenrezept Cialis 20 Mg Comprimes Pellicules

__________

ylq says:

2017-11-27 23:10:58

http://chiefs.nfl-jerseys.org/, http://www.adidas-store.net/, http://www.raybans.org.es/, http://www.the-northface.ca/, http://ravens.nfl-jerseys.org/, http://raiders.nfl-jerseys.org/, http://www.nike-free5.com/, http://www.outlet-pradahandbags.com/, http://www.versace-outletonline.com/, http://www.burberryoutlet-inz.co.uk/, http://www.jackets-thenorthface.com/, http://www.northfacejackets.fr/, http://www.vans-shoesoutlet.co.uk/, http://spurs.nba-jersey.com/, http://www.cheap-baseballbats.us/, http://lions.nfl-jerseys.org/, http://www.christian-louboutin.jp.net/, http://www.michaelkorsoutlet.mex.com/, http://www.ferragamo.net.co/, http://www.christianlouboutins-shoes.co.uk/, http://www.outlet-pradabags.com/, http://www.coach-outlet.net.in/, http://www.mcm-bagsoutlet.com/, http://www.air-huarache-shoes.co.uk/, http://www.tommy-hilfigers.de/, http://www.soccershoes.us.com/, http://www.new-balanceshoes.com/, http://www.cheapshoes.net.co/, http://www.airmax.com.se/, http://www.nikeshoes-outlet.com/, http://www.nba-jersey.com/, http://broncos.nfl-jerseys.org/, http://www.coachfactory.cc/, http://www.hollister.com.se/, http://heat.nba-jersey.com/, http://www.hollister-store.com.co.co/, http://www.rayban-sunglasses.fr/, http://www.oakleys-outlets.net/, http://www.nikeair-max.ca/, http://hawks.nba-jersey.com/, http://hornets.nba-jersey.com/, http://www.armani-outlet.com/, http://www.kate-spadebags.com/, http://www.oakleys-sunglass.com.co/, http://www.philipp-pleins.com/, http://www.cheap-jordans.com.co/, http://www.michaels-korsoutlet.com/, http://www.replica-handbags.com.co/, http://www.oakley-sunglassessale.com.co/, http://www.nike-airmax.com.de/, http://www.oakley-sbocco.it/, http://www.asicsoutlet.net/, http://www.australia-oakleysunglasses.com/, http://www.nba-shoes.com/, http://www.dsquared2s.com/, http://www.adidas-shoes.ca/, http://falcons.nfl-jerseys.org/, http://titans.nfl-jerseys.org/, http://steelers.nfl-jerseys.org/, http://www.longchamp-outlet.com.co/, http://www.ralph-lauren-polos.us.org/, http://www.ralphlauren-polos.com.co/, http://www.nike-shoesoutlet.com/, http://www.michaelkors.so/, http://www.thomassabos-jewelrys.co.uk/, http://www.iphone-cases.net/, http://www.newbalance-canada.ca/, http://panthers.nfl-jerseys.org/, http://chargers.nfl-jerseys.org/, http://www.reebok-shoes.co.uk/, http://www.oakleys.org.es/, http://mavericks.nba-jersey.com/, http://www.juicy-coutureoutlet.com/, http://www.oakleysoutlet.com.co/, http://www.michael-korsukpurse.co.uk/, http://www.nike-rosherun.co.nl/, http://warriors.nba-jersey.com/, http://www.omegas-relojes.es/, http://www.outlet-toryburch.com/, http://www.jerseys-store.com/, http://www.polos-ralphlauren.com.co/, http://www.vansschuhe.com.de/, http://www.bottega-venetasoutlet.com/, http://www.outlets-polo.com/, http://www.zcoachoutlet.com/, http://www.nikeshoes.de/, http://www.mcm-backpacks.com.co/, http://www.nike-maxshoes.fr/, http://www.hogans.com.de/, http://www.ed-hardy.us.com/, http://www.cheap-iphonecases.com/, http://www.levis-jeansoutlet.com/, http://www.ferragamos.us.com/, http://www.louboutinshoes.jp.net/, http://www.barboursjackets.com/, http://www.nike-airmaxsc.co.uk/, http://www.asicsoutlet.com.co/, http://browns.nfl-jerseys.org/, http://www.airjordans-shoes.com/, http://www.the-northface.com.de/, http://www.cheap-jerseys.mex.com/, http://buccaneers.nfl-jerseys.org/, http://www.barbours.us.com/, http://www.rolexwatch-outlet.com/, http://www.outlet-mkors.com/, http://www.nike-shoesoutlet.us.org/, http://www.montblancpences.com/, http://www.michael-korsoutletonline.com.co/, http://www.coachoutletonlinemall.com/, http://www.coachoutlet-online.com.co/, http://www.polosoutlet-store.com/, http://www.eyeglassesinsale.com/, http://www.nike-paschers.fr/, http://www.valentino-shoesoutlet.us.com/, http://pelicans.nba-jersey.com/, http://www.marc-jacobs.us.com/, http://www.michaelkors.co.nl/, http://www.timberlandspaschere.fr/, http://www.danskoshoes.in.net/, http://www.burberry


Add your comment on this article below:

Sorry, there's an error with your form entries. We really appreciate your comment, so please try again.

Form submitting now...

Name:

Website:

Email address (not displayed):

Enter your comment below: