Menu
I’m working on creating an upload site, but I need an upload script that will upload any file and has a [B]progress bar
can anyone help???
thanks.
<i>
</i><?
error_reporting(0);
$maxsize="3072";
$randomname="1";
$usetypes="1";
$types=array("jpg", "png", "bmp", "jpeg", "gif", "png", "zip", "rar");
$url="http://insanefiles.com/uploads/";
$folder="./uploads/";
$fullpath="";
$textcolor="#000000";
$textface="verdana";
$textsize="15px";
$pagebg="#CDCDCD";
$tablebg="#FFFFFF";
?>
<html>
<head>
<title>insanefiles.com</title>
</head>
<style type="text/css">
a {color:blue;}
a {text-decoration:none; ;}
body{background-color:<?Echo($pagebg);?>;}
.text{font-face:<?Echo($textface);?>; font-size:<?Echo($textsize);?>; font-color:<?Echo($textcolor);?>;}
input{font-face:<?Echo($textface);?>; font-size:<?Echo($textsize);?>; font-color:<?Echo($textcolor);?>;}
</style>
<body>
<form action="<?echo $_SERVER['PHP_SELF'];?>" method="POST" enctype="multipart/form-data">
<table border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse" bordercolor="#000000" width="400" align="center" bgcolor="<?Echo($tablebg);?>" class="text">
<tr>
<td colspan="2" align="center"><b>Allowed Types:</b> <?Echo(implode(", ",$types))?></td>
</tr>
<tr>
<td colspan="2" align="center"><b>Max File Size:</b> <?If(!$maxsize){Echo("No Limit");}Else{Echo($maxsize."kb");}?></td>
</tr>
<tr>
<td><b>Select file to upload:</b> </td>
<td><input type="file" name="file"></td>
</tr>
<tr>
<input type="hidden" name="doupload" value="True">
<td colspan="2" align="center"><input type="submit" name="doupload" value=" Upload File "> <input type="reset" name="reset" value=" Reset Form "></td>
</tr>
</table>
</form>
<?
If($fullpath){$folder=$fullpath;}
If(!$fullpath) {
$folder2=str_replace(".","",str_replace("/","",$folder));
If(!is_dir($folder2)) {
Echo("");
If(!@mkdir($folder2)) {
exit("");
} Else {
Echo("");
<i> </i> If(!@chmod($folder2,octdec("0777"))) {
<i> </i> exit("");
<i> </i> } Else {
<i> </i> Echo("");
<i> </i> }
<i> </i> }
<i> </i> }
}
If($_POST['doupload']) {
$file=$_FILES['file']['tmp_name'];
$size=$_FILES['file']['size'];
$type=$_FILES['file']['type'];
$name=strtolower($_FILES['file']['name']);
$ext=substr(strrchr($name, "."), 1);
$ext=str_replace("jpeg", "jpg", $ext);
<i> </i> If($randomname){
<i> </i> $rand=rand(0,100);
<i> </i> $name=$rand."_".time().".".$ext;
<i> </i> }
<i> </i> $error="";
<i> </i> If(!$file) {
<i> </i> $error="1";
<i> </i> $text .="<b>No file selected</b><br />n";
<i> </i> }
<i> </i> If($file) {
<i> </i> If($maxsize) {
<i> </i> If($size > ($maxsize*1024)) {
<i> </i> $error="1";
<i> </i> $text .="<b>Your file is to big</b><br />n";
<i> </i> }
<i> </i> }
<i> </i> If($usetypes) {
<i> </i> If(!in_array($ext,$types)) {
<i> </i> $error="1";
<i> </i> $text .="<b>Invalid file type</b><br />n";
<i> </i> }
<i> </i> }
<i> </i> If(file_exists($folder.$name)) {
<i> </i> $error="1";
<i> </i> $text .="<b>Please rename your file.<br /></b><br />n";
<i> </i> }
<i> </i> }
<i> </i> If($error=="1") {
<i> </i> Echo("<div align="center" class="text">$text</div>n");
<i> </i> @unlink($file);
<i> </i> } Else {
<i> </i> @move_uploaded_file($file,$folder.$name) or die("Couldn't copy file to server, please make sure ".$folder." is chmod 777.");
<i> </i> exit("<div align="center" class="text"><b>File uploaded! <br /><br />Your file: <font color=blue><a href=".$url.$name.">".$url.$name."</a></font></b><br /><br /></div>n");
<i> </i> }
}
?>
another thing, the site ishttp://insanefiles.com , check it out, the problem I have is when I upload a .fla or .psd or .php and maybe a few others, they upload, but I can't view them nor can I download them as I normally would be able to, anyone know what's wrong with it???
http://insanefiles.com
thanks.[/QUOTE]
<i>
</i>$types=array("jpg", "png", "bmp", "jpeg", "gif", "png", "zip", "rar");
0.1.9 — BETA 5.19