Salve,
ho un errore abbastanza insolito ... isi tratta di un upload di un file in cui ho settato la massima dimensione file ed estensione. In alcuni casi e random non funziona.
Se carico un fle sui 50 kb va sempre bene ma da quando si inizia a salire in dimensione dà problemi.
Con firefox 1.5 il risultato è il seguente
"The connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try again in a few
moments.
* If you are unable to load any pages, check your computer's network
connection.
* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web."
strano perchè è lo stesso script che ho usato in precedenza sempre sullo stesso server e in quello di sviluppo funziona.
vi posto il codice
codice:
<?
///// CONFIGURAZIONE
/////
/////
$CfgMaxDimFile = 2000000; // 2Mb
$CfgMessageMaxDimFile = "Hai superato la dimensione consentita";
$CfgMessageNoFile = "Nessun File selezionato";
$CfgDirUpload = "/tmp";
ob_start();
session_start();
$ErrorDetect = "";
if ($_GET['invio'] == "invio") {
if ($HTTP_POST_FILES['filename']['name']!= "") {
$ErrorDetect = 0;
$_SESSION['NameFileUser'] = "";
$_SESSION['NameFileServer'] = "";
if ($HTTP_POST_FILES['filename']['size']<$CfgMaxDimFile){
if ($HTTP_POST_FILES['filename']['size']==0){ // se supero la dimensione massima del server nel php.ini
$FinalErrorMessage = $CfgMessageMaxDimFile . " di " . $CfgMaxDimFile . " byte";
$ErrorDetect = 1;
} else {
$FinalFileToServer = pathinfo($HTTP_POST_FILES['filename']['name']);
$ExtFinalFile = $FinalFileToServer["extension"];
if (($ExtFinalFile=="php") || ($ExtFinalFile=="php3") || ($ExtFinalFile=="pl") || ($ExtFinalFile=="c") || ($ExtFinalFile=="sh") || ($ExtFinalFile=="bat") || ($ExtFinalFile=="com") || ($ExtFinalFile=="gz") || ($ExtFinalFile=="tar")){
$FinalErrorMessage = $CfgMessageNoFile;
$ErrorDetect = 1;
} else {
$my_ip = explode(".",$HTTP_SERVER_VARS['REMOTE_ADDR']);
$my_ip = $my_ip[0].$my_ip[1].$my_ip[2].$my_ip[3];
$StringaNameFile = date("Ymd").date("His")."_".$my_ip.".".$ExtFinalFile;
@copy($HTTP_POST_FILES['filename']['tmp_name'], "$CfgDirUpload/$StringaNameFile") or die("Non è stato possibile effettuare l'upload del file ");
$_SESSION['NameFileServer'] = "$CfgDirUpload/$StringaNameFile";
$_SESSION['NameFileUser'] = $HTTP_POST_FILES['filename']['name'];
}
}
}else{ // se supero la dimensione massima del che imposto nel config.php
$FinalErrorMessage = $CfgMessageMaxDimFile . " di " . $CfgMaxDimFile . " byte";
$ErrorDetect = 1;
}
} else { // se la form è vuota
$FinalErrorMessage = $CfgMessageNoFile;
$ErrorDetect = 1;
}
//print $FinalErrorMessage;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #E1E1E1;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
color: #FFFFFF;
font-size: 13px;
}
.style3 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
}
.style9 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; font-weight: bold; }
-->
</style>
</head>
<body>
<table width="150" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td>
<table width="100%" height="52" border="0" cellpadding="0" cellspacing="0" class="areariservata_back">
<tr>
<td width="525" align="center">
<?
if ($ErrorDetect==0){?>
<center>
<span class="undicipx">
<? if ($_SESSION['NameFileUser'] != "") { ?>
Upload del file <? print $HTTP_POST_FILES['filename']['name'];?> effettuato con successo!
<? } ?>
<script language="javascript">
opener.document.getElementById("nomecampo").innerHTML="";
opener.document.getElementById("nomecampo").innerHTML="<span><? print $HTTP_POST_FILES['filename']['name'];?></span>";
self.close();
</script>
</span>
</center>
<? } else { ?>
<center>
<span class="undicipx">
<? print $FinalErrorMessage;?>
attendere il redirect alla form
</span>
<meta http-equiv="Refresh" content="2; url=/upload_file.php?inviofile=inviofile">
</center>
<? } ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?
}
?>
<?
if ($_GET['inviofile'] == "inviofile") {
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Upload File</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
background-color: #E1E1E1;
}
.style2 { font-family: Arial, Helvetica, sans-serif;
color: #FFFFFF;
font-size: 13px;
}
.style3 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
color: #FFFFFF;
}
.style9 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF; font-weight: bold; }
-->
</style>
</head>
<script language="javascript">
function checkForm() {
f = document.PWS;
if (f.filename.value == "") {
alert("Selezionare un file!");
return false;
}
return true;
}
</script>
<body>
<FORM METHOD="Post" ENCTYPE="multipart/form-data" onSubmit="return checkForm();" ACTION="/upload_file.php?invio=invio" id="form2" name="PWS">
<table width="150" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td valign="top" class="align_center">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="align_center">
<td class="testo_notizia">Allega un file</td>
</tr>
</table
></td>
</tr>
<tr>
<td>
<input name="filename" type="file" class="button">
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td class="align_center">
<input name="Submit" type="submit" class="button" value="Invia">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<? } ?>
grazie ... se avete modo di provarlo sulle vostre macchine in particolar modo con file dai 500 kb ai 2 Mb