View Full Version : Html Uploader Help +Rep
Swastika
05-12-2006, 03:43 PM
Ok
So im making a little uploader in html on dreamweaver.
So i have the "choose file" tab where you click it and you choose which file you want to upload.
Then i have a "upload" tab, but i carnt figure out how to make it make you go to a page where it shows your file and links to it?
+Rep will be awarded to people who give advice that works.
Thanks very much!
-Jamie
Dentafrice1
05-12-2006, 03:54 PM
http://www.tizag.com/phpT/fileupload.php
;)
Swastika
05-12-2006, 04:11 PM
Thanks so much mate.
+Rep! :D
<?php
# Not tested. Use at your own risk.
$exts[] = 'jpg';
$exts[] = 'jpeg';
$exts[] = 'png';
$exts[] = 'gif';
$exts[] = 'txt';
define('dir', 'files/');
define('err', 'Opps! A problem occured.');
define('seed', '"!Fqi346kF2W_j*');
if($_POST['userfileupload']) {
$tmpname = $_FILES['userfile']['tmp_name'];
$ext = substr(strrchr(strtolower($_FILES['userfile']['name']), "."), 1);
list($width, $height) = getimagesize($tmpname);
$hash = md5(seed.file_get_contents($tmpname));
if(!is_uploaded_file($tmpname))die(err);
if($_FILES['userfile']['error']>0)die(err);
if(!in_array($ext, $exts))die(err);
if(isset($width)&&($width>1500||$height>1500))die(err);
if($_FILES['userfile']['size']>100000)die(err);
if(!file_exists($dir.$hash.$ext)) copy($tmpname, dir.$hash.'.'.$ext);
print('File Uploaded');
} else {
$self = htmlentities($_SERVER['PHP_SELF']);
print <<<HTML
<form method="POST" action="{$self}" enctype="multipart/form-data">
<input type="file" name="userfile" />
<input type="submit" name="userfileupload" />
</form>
HTML;
}
?>
I might have made some errors, and I'm not sure if it's 100% secure, so use it at your own risk..
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2026 vBulletin Solutions Inc. All rights reserved.