Ajax Java Upload Status

Sziebeck

Mitglied
Hallo zusammen ,da ich schon öfter hier meine Probleme durch euch lösen konnte ,möchte ich es heute hier wieder versuchen.

Ich würde gerne mein Upload mit einer Status/Speed anzeige versehen.nun habe ich gesehen ,das hier viele Lösungsansätze gepostet wurden.
Ich bin aber leider in dieser hinsicht zu doof das ganze einzubauen (swf uploader,Fancyupload)

Nun meine Frage an euch ,könntet Ihr mir dabei helfen ?

Hier wäre mein Upload Form :
PHP:
<?php

require_once("./config.php");

if(in_array($language, $LANGUAGE_LIST)) {
  include('./lang/'.$language.'.php');
} else {
  include('./lang/'.$LANGUAGE_LIST[0].'.php');
}
?>
<center>
<style type="text/css">
div.fileinputs {
	position: relative;
}

div.fakefile {
	position: absolute;
	top: 0px;
	left: 0px;
	z-index: 1;
}

input.file {
	position: relative;
	text-align: right;
	-moz-opacity:0 ;
	filter:alpha(opacity: 0);
	opacity: 0;
	z-index: 2;
}

</style>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META NAME="revisit-after" CONTENT="2 days">
<link rel="SHORTCUT ICON" href="favicon.ico">
<script type="text/javascript">
function CancelUpload() {
  alert("Cancel Upload now");
    if (confirm("Are you sure to cancel Upload now?")) {
      window.location = "index.php";
    }
    else
      alert("Upload Resumed."); {
    }
}
</script>
<SCRIPT language="JavaScript">
var checkobj
function agreesubmit(el){
checkobj=el
if (document.all||document.getElementById){
for (i=0;i<checkobj.form.length;i++){  //hunt down submit button
var tempobj=checkobj.form.elements[i]
if(tempobj.type.toLowerCase()=="submit")
tempobj.disabled=!checkobj.checked
}
}
}

function defaultagree(el){
if (!document.all&&!document.getElementById){
if (window.checkobj&&checkobj.checked)
return true
else{
alert("Please read and accept terms to submit form")
return false
}
}
}
</script>
<script type="text/javascript"><!--
function agreeTerms()
{
document.getElementById("upload").disabled=false
document.getElementById("checkBox").checked=true
}
function denyTerms()
{
document.getElementById("upload").disabled=true
document.getElementById("checkBox").checked=false
}

var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
	fakeFileUpload.appendChild(document.createElement('input'));
	var image = document.createElement('img');
	image.src='button_select.gif';
	fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].onchange = x[i].onmouseout = function () {
			this.relatedElement.value = this.value;
		}
	}
}

//--></script>

<!-- flooble Expandable Content header start -->
<script language="javascript">
// Expandable content script from flooble.com.
// For more information please visit:
//   http://www.flooble.com/scripts/expand.php
// Copyright 2002 Animus Pactum Consulting Inc.
//----------------------------------------------
var ie4 = false; if(document.all) { ie4 = true; }
function getObject(id) { if (ie4) { return document.all[id]; } else { return document.getElementById(id); } }
function toggle(link, divId) { var lText = link.innerHTML; var d = getObject(divId);
 if (lText == '+') { link.innerHTML = '-'; d.style.display = 'block'; }
 else { link.innerHTML = '+'; d.style.display = 'none'; } }
</script>
<!-- flooble Expandable Content header end   -->
</head><center>
<body onload="denyTerms()">
<tr><td >
  	<? include("./ads.php"); ?>
<p><center><? echo $lang[info];?></center></p>

<h1><center><? echo $lang[upload];?></center></h1>
	<br />
	<center>
	<form enctype="multipart/form-data" action="upload.php?do=verify" id="form" method="post" onsubmit="a=document.getElementById('form').style;a.display='none';b=document.getElementById('part2').style;b.display='inline';" style="display: inline;">
	<? echo $lang[maxsize];?> <b><?php echo $maxfilesize; ?> MB</b><br />
         <table align="center" border=0 cellspacing=0 cellpadding=2><tr><td align=center colspan=2>
	<?php echo $filetypes; ?>
	<tr><td align=left> </td>
<img src="img/bild.gif">
<input type="file" name="upfile" />
</td></tr>
         <tr><td align=left>
	<?php if($emailoption) { ?><? echo $lang[emailopt];?>:</td><td ><input type="text" name="myemail" size="40" /> <i>(<? echo $lang[opt];?>)</i></td></tr><?php } ?>
	<tr><td align=left><?php if($descriptionoption) { ?><? echo $lang[desopt];?>:</td><td align=right><input type="text" name="descr" size="40" /> <i>(<? echo $lang[opt];?>)</i></td></tr><?php } ?>
	<tr><td align=left><?php if($passwordoption) { ?><? echo $lang[passopt];?>:</td><td align=right><input type="text" name="pprotect" size="40" /> <i>(<? echo $lang[opt];?>)</i></td></tr><?php } ?>
         <tr><td align=center colspan=2><?php if(isset($categorylist)) { echo $categorylist; } ?></td></tr></table>
	<input type="checkBox" onclick="if (this.checked) {agreeTerms()} else {denyTerms()}"> <? echo $lang[sinfo];?> <a href="?page=tos"><? echo $lang[tos];?></a>. 
<INPUT TYPE="image" SRC="/images/submit.gif" BORDER="0" ALT="submit" value="Upload!" id="upload">

</center>
	</form>
         <div id="part2" style="display: none;">
<script language="javascript" src="xp_progress.js"></script>
<? echo $lang[progress];?>
<BR><BR>
<script type="text/javascript">
var bar1= createBar(300,15,'white',1,'black','orange',100,7,1,"");
</script>
<br>
<div align="center">
<form>

<input type="button" value="Cancel Upload" onclick="CancelUpload()">
</form>
</div>
</div>	<br />
<p>	
</center></td></tr></table>

und hier die Datei , wenn der Upload fertig ist :

PHP:
<?php

require_once("./config.php");
include("./header.php");

if(in_array($language, $LANGUAGE_LIST)) {
  include('./lang/'.$language.'.php');
} else {
  include('./lang/'.$LANGUAGE_LIST[0].'.php');
}

$junk = array('.' , ',' , '/' , '\\' , '`' , ';' , '[' , ']' , '-', "'", '*', '&', '^', '%', '$', '@', '!', '~', '+', '(', ')', '|', '{', '}', ' ', '?', ':', '"', '=', "<", ">", " &");
$multi = array('__', '___', '____', '_____', '______');

$filename = $_FILES['upfile']['name'];
$filename = str_replace("'",'',"$filename");
$filename = str_replace("&",'',"$filename");
//$filename = str_replace(" ",'%20',"$filename");
$filename = stripslashes("$filename");
$filesize = $_FILES['upfile']['size'];
function GeneratePassword($length = 15) {
//Funktion zur Generierung eines zufälligen Passworts

$char_control  = "";
$chars_for_pw  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$chars_for_pw .= "0123456789";

$chars_for_pw .= "abcdefghijklmnopqrstuvwxyz";
srand((double) microtime() * 1000000);
for($i=0;$i<$length;$i++) {
$number = rand(0, strlen($chars_for_pw));
$char_control .= $chars_for_pw[$number];
}
            
return $char_control;

} 



$fancyurl=rand('1','999');

#$rand2=("GeneratePassword(); ");
$rand2=GeneratePassword();



$m=$shourturl;
if ($m=="true")
  $short= "";
else
  $short= "download.php?file=";

$bans=file("./secure/bans.mfh");
foreach($bans as $line)
{
  if ($line==$rand2."\n"){
?> <center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
<?
    echo "$lang[noallow]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
  }
  if ($line==$_SERVER['REMOTE_ADDR']."\n"){
?><center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>
   <? echo "$lang[nallow]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
    include("./footer.php");
    die();
  }
}

if(isset($allowedtypes)){
$allowed = 0;
foreach($allowedtypes as $ext) {
  if(substr($filename, (0 - (strlen($ext)+1) )) == ".".$ext)
    $allowed = 1;
}
if($allowed==0) {
?><center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
   echo "$lang[itype]";
   ?></center></td></tr></table><p style="margin:3px;text-align:center"><?
include("./footer.php");
   die();
}
}

if(isset($categorylist)){
$validcat = 0;
foreach($categories as $cat) {
  if($_POST['category']==$cat || $_POST['category'] = ""){ $validcat = 1; }
}
if($validcat==0) {
?><center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
   echo "$lang[icat]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
   include("./footer.php");
   die();
}
$cat = $_POST['category'];
} else { $cat = ""; }

if($filesize==0) {
?><center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
echo "$lang[dpick]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
include("./footer.php");
die();
}

$filesize = $filesize / 1048576;

if($filesize > $maxfilesize) {
?><center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top><?
echo "$lang[tlarge]";
?></center></td></tr></table><p style="margin:3px;text-align:center"><?
include("./footer.php");
die();
}

$userip = $_SERVER['REMOTE_ADDR'];
$time = time();

if($filesize > $nolimitsize)
{
$newfile = "./uploader/".$userip.".mfh";
$f=fopen($newfile, "w");
fwrite ($f,$userip."|".$time."|");
fclose($f);
chmod($newfile,0777);
}

$passkey = rand(100000, 999999);

if($emailoption && isset($_POST['myemail']) && $_POST['myemail']!="") {
$rand2 = urlencode($rand2);
$uploadmsg = "$lang[ufile] (".$filename.") $lang[wup].\n  ". $lang[udownfile] . ":" . $scripturl . "$short" . $rand2 . "\n ". $lang[udeletefile] . ":" . $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . "\n $lang[thank]";
mail($_POST['myemail'],"Your Uploaded File",$uploadmsg,"From: ". $email ."\n");
$rand2 = urldecode($rand2);
}

if($passwordoption && isset($_POST['pprotect'])) {
  $passwerd = md5($_POST['pprotect']);
} else { $passwerd = md5(""); }

if($descriptionoption && isset($_POST['descr'])) {
  $description = strip_tags($_POST['descr']);
} else { $description = ""; }

$filelist = fopen("./files/".$rand2.".mfh","w");
fwrite($filelist, $rand2 ."|". basename($_FILES['upfile']['name']) ."|". $passkey ."|". $userip ."|". $time."|0|".$description."|".$passwerd."|".$cat."|".$_POST['pprotect']."|\n");

$movefile = "./storage/" . $rand2;
move_uploaded_file($_FILES['upfile']['tmp_name'], $movefile);

?>
<center><table align="center"  style="margin-top:0px;width:790px;height:400px;"><tr><td style="border:1px #AAAAAA solid;height:100%;background-color:#FFFFFF;padding:20px;text-align:left;" valign=top>

<?
include("./ads.php");
echo "<center><b> $lang[yupfile] </b></center><br />";
echo "<center> $lang[udownfile] </center> <p><center> <a href=\"" . $scripturl . "$short" . $rand2 . "\">". $scripturl . "$short" . $rand2 . "</a><br />";
echo "<p><center> $lang[udeletefile] </center> <p><center> <a href=\"" . $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . " \">". $scripturl . "$short" . $rand2 . "&del=" . $passkey . "&ignore=" . "</a><br />";
echo "<p><center> $lang[uremfile]."; ?><p><?


?>
  </td></tr></table></center>
<?

include("./footer.php");
?>

Wäre echt genial ,wenn Ihr mir helfen könntet :)

Gruss
Sven
 

Neue Beiträge

Zurück