Ciao a tutti,
ho uno script che tramite le funzioni FTP mi carica online un file .zip
Finchè si tratta di file di 4-5 MB non c'è problema, ma se provo a mettere su un file + pesante (20mb) mi da errore e non mette su un bel niente..
Utilizzo una ADSL a 1,2 mb..
Sto utilizzando l'ottima classe WEB3FTP scaricata da phpclasses.org
Codice PHP:
<?php
/*
=============== WEB3FTP =============
Copyright Angelo Gelmi - 2004
Example 1:
Upload a file kept in your server filesystem to an another server
include "w3k.ftmp.php";
$ftpconnection = new web3ftp("hostofanotherserver","username","password");
$ftpconnection->upload("./filename.ext","/remotedirectory/filename");
$ftpconnection->close;
Example 2:
Upload a file kept in /tmp by a form upload (if your server avoid set permission 777 onto a directory)
to a directory on the same server.
include "w3k.ftmp.php";
$ftpconnection = new web3ftp("localhost","username","password");
$ftpconnection->upload($_FILES["the_file"]["tmp_name"],"img/novita/".$_FILES["the_file"]["name"]);
$ftpconnection->close;
*/
class web3ftp {
var $verbose;
function web3ftp($ftp_server,$ftp_user,$ftp_password){
$this->ftp_server=$ftp_server;
$this->ftp_user=$ftp_user;
$this->ftp_password=$ftp_password;
$this->max_size=500000;
$this->connection($this->ftp_server,$this->ftp_user,$this->ftp_password);
$this->allowed = array ("image/jpeg","image/gif","image/png","image/psd");
//$this->verbose=1;
}
//===================================
// Make connection to server
//===================================
function connection(){
//print $this->ftp_user.",".$this->ftp_password."
";
$this->conn_id = ftp_connect($this->ftp_server);
$login_result = ftp_login($this->conn_id, $this->ftp_user, $this->ftp_password);
if (($this->conn_id==false) || ($login_result==false)) {
echo "FTP connection aborted!";
echo "Connection to $this->ftp_server for user $this->user failed!";
die;
} else {
if ($this->verbose==true)
echo "Connected at $this->ftp_server, user $this->ftp_user";
}
}
//===================================
// Upload File (localfile,remotefile)
//===================================
function upload($source_file,$destination_file){
// if file name not specified alert and exit
// otherwise make the upload
if ((!isset($source_file))||(!isset($destination_file))){
echo "Some mandatory file not specified!
";
echo "Verify origin_file and destination_file.";
} else {
$upload = ftp_put ($this->conn_id, $destination_file, $source_file, FTP_BINARY);
// controllo dello stato di upload
if ($upload==false) {
echo "
FTP Loading didn't succeded - SOURCE $source_file";
} else {
//$this->changePermission($destination_file,744);
if ($this->verbose==true)
echo "
Correctly loaded file $source_file on $this->ftp_server as $destination_file";
}
}
}
//===================================
// Delete File (remotefile)
//===================================
function delete($destination){
if (isset($destination)){
if (@ftp_delete ( $this->conn_id, $destination)){
if ($this->verbose==true)
echo "Removed $destination at $this->ftp_server";
}else{
//Errors
if ($this->verbose==true)
echo "Some errors occourred during removing:
".$destination;
}
}
}
//===================================
// Change Permission To File (remotefile,permission)
//===================================
function changePermission($file,$permission){
if (isset($file) && isset($permission))
return ftp_chmod ($this->conn_id,$permission,$file);
}
//===================================
// Verify parameters (weigth,mime )
//===================================
function checkparam($inputname){
$lock="";
if($_FILES[$inputname]['size']>$this->max_size){
$this->err = "La dimensione eccede quella massima consentita ($this->max_size byte)";
return 1;
}
// Parsa i mime consentiti
if (!in_array ($_FILES[$inputname]['type'], $this->allowed)){
if ($this->verbose==true){
$this->err = "Il tipo di immagine non è tra quelli consentiti
";
$this->err .= $_FILES[$inputname]['type']."( ";
foreach ($this->allowed as $permitted)
$this->err.= "[b]".$permitted."[/b], ";
$this->err .= ") ";
return 2;
}
}
return 0;
}
//===================================
// Close connection
//===================================
function close(){
ftp_quit($this->conn_id);
}
}
?>
Questo è il mio script:
Codice PHP:
$ftpconnection = new web3ftp("localhost","user","psw");
if(!is_file($path_dir."/".$cliente."/".$dir_name."/".$_FILES['source_file']['name'])){
$ftpconnection->upload($_FILES["source_file"]["tmp_name"],"public/area_clienti/".$cliente."/".$dir_name."/".$_FILES["source_file"]["name"]);
$ftpconnection->close;
//etc etc
C'è forse qualche funzione x settare il tempo di esecuzione dei files??