PDA

View Full Version : Free image hosting


ThunderPoit
2004-07-27, 19:34
Hey guys, i just wanted to let anyone know that if they want a place to host their images, i have section set up on my webserver so that you can. All i ask is that you please do not abuse this service and only use it for hosting on this forum.

Image Hosting (http://www.davidlegatt.com/upload.php)

SilentEchoes
2004-07-27, 19:55
You want me to fix that script for you so they CAN'T overwrite some one's image?

DMBand0026
2004-07-27, 20:12
You might also want to warn the kiddies that a good bit of stuff housed on the aforementioned server is not safe for work. :)

ThunderPoit
2004-07-27, 20:46
ahh, ya, forgot about that bit


if you want to fix it, heres the code :

<?php

$site_name = $_SERVER['HTTP_HOST'];
$url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

$upload_dir = "pix/";
$upload_url = $url_dir."pix/";
$message ="";

//create upload_files directory if not exist
//If it does not work, create on your own and change permission.
if (!is_dir("pix")) {
die ("pix directory doesn't exist");
}

if ($_FILES['userfile']) {
$message = do_upload($upload_dir, $upload_url);
}
else {
$message = "Invalid File Specified.";
}

print $message;

function do_upload($upload_dir, $upload_url) {

$temp_name = $_FILES['userfile']['tmp_name'];
$file_name = $_FILES['userfile']['name'];
$file_type = $_FILES['userfile']['type'];
$file_size = $_FILES['userfile']['size'];
$result = $_FILES['userfile']['error'];
$file_url = $upload_url.$file_name;
$file_path = $upload_dir.$file_name;

//File Name Check
if ( $file_name =="") {
$message = "Invalid File Name Specified";
return $message;
}
//File Size Check
else if ( $file_size > 500000) {
$message = "The file size is over 500K.";
return $message;
}
//File Type Check
else if ( $file_type == "text/plain" ) {
$message = "Sorry, You cannot upload any script file" ;
return $message;
}

$result = move_uploaded_file($temp_name, $file_path);
$message = ($result)?"File url <a href=$file_url>$file_url</a>" :
"Somthing is wrong with uploading a file.";

return $message;
}
?>
<form name="upload" id="upload" ENCTYPE="multipart/form-data" method="post">
Upload Image<input type="file" id="userfile" name="userfile">
<input type="submit" name="upload" value="Upload">

</form>
<p>
This is a free service provided by me, I won't be here to moderate it every five seconds, so i urge yo\
u to not abuse this as i can take it away at any time. Below is a list of currently uploaded files, p\
lease choose a unique name for yours so you do not overwrite somone else's image.

<br>

<iframe src="/pix/" height="80%">
</iframe>

PXLpainter
2004-07-27, 21:23
I saw this bizzare preview in the movie theater this past weekend for Agent155.com - so I went to check it out and it's for artists, musicians, actors, filmakers, etc... and they are offering free accounts for the next month or so - with 500MB of portfolio storage space and a template for your portfolio page. Doesn't seem like there's many strings attached, so if you fit the bill, check it out! It never hurts to have too much publicity!

(well, unless you're Michael Jackson, that is!) :wow: :err: :eek:

SilentEchoes
2004-07-27, 22:17
I'll take a look at it sometime tomorrow. I have to finish up some stuff for work tonight. I'll have it back at ya tomorrow, all you gotta do is load the dir into an array and check and see if the uploaded file is in the array, if it is use die to give them an error.

ThunderPoit
2004-07-27, 22:37
ya, i figured as much. its just been so long since ive done php that it'd take me a few days to get working