2010-08-10 72 views
0

我使用uploadify在一個項目中使用以下腳本:Uploadify的sizeLimit問題

$(document).ready(function() { 

    $("#uploadify").uploadify({ 
     'uploader': '_assets/flash/uploadify.swf', 
     'script': 'uploadify.php', 
     'cancelImg': '_assets/images/nav/cancel.png', 
     'folder': 'uploads', 
     'queueID': 'fileQueue', 
     'auto': true, 
     'multi': true, 
     'sizeLimit': 20971520, 
     'fileExt': '*.eps;*.jpg;*.pdf;*.psd;*.mov;*.ai;*.png;*.doc;*.docx;*.ppt;*.pptx;*.indd;*.bmp;*.dwg;*.pct;*.txt;*.wmv', 
     'fileDesc': 'We accept graphics and text files only!', 
     'buttonImg': '_assets/images/nav/uploadbutton.png', 
     'wmode': 'transparent', 
     'width': 143, 
     'height': 53, 
     onAllComplete: function() { 
      $('#forupload').hide(); 
      $('#confirm').fadeIn(); 
     } 
    }); 

}); 

php文件,這使得請求是uploadify.php:

error_reporting(E_ALL); 


if (!empty($_FILES)) { 
    $tempFile = $_FILES['Filedata']['tmp_name']; 
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/'; 
    $targetFile = str_replace('//','/',$targetPath) . $_FILES['Filedata']['name']; 

    // $fileTypes = str_replace('*.','',$_REQUEST['fileext']); 
    // $fileTypes = str_replace(';','|',$fileTypes); 
    // $typesArray = split('\|',$fileTypes); 
    // $fileParts = pathinfo($_FILES['Filedata']['name']); 

    // if (in_array($fileParts['extension'],$typesArray)) { 
     // Uncomment the following line if you want to make the directory if it doesn't exist 
     // mkdir(str_replace('//','/',$targetPath), 0755, true); 

     move_uploaded_file($tempFile,$targetFile); 
     echo "1"; 



    //Send confirmation email 

    require_once('_mailClasses/class.phpmailer.php'); 
    include_once("_mailClasses/class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded 

    $mail    = new PHPMailer(); 

    $body    = 'There is a new online order. Please check your order folder.'; 
    //$body    = eregi_replace("[\]",'',$body); 

    $mail->IsSMTP(); // telling the class to use SMTP 
    $mail->Host  = "mail.splashoflondon.com";  // SMTP server 
    $mail->SMTPDebug = 2;        // enables SMTP debug information (for testing) 
    // 1 = errors and messages 
    // 2 = messages only 
    $mail->SMTPAuth = true;       // enable SMTP authentication 
    $mail->Host  = "mail.splashoflondon.com";  // sets the SMTP server 
    $mail->Port  = 25;       // set the SMTP port for the GMAIL server 
    $mail->Username = "[email protected]"; // SMTP account username 
    $mail->Password = "blablabla";      // SMTP account password 

    $mail->SetFrom('[email protected]', 'Splash of London'); 

    $mail->AddReplyTo("[email protected]","Adolphus"); 

    $mail->Subject = "Online Order"; 

    $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test 

    $mail->MsgHTML($body); 

    $address = "[email protected]"; 
    $mail->AddAddress($address, "Splash Order Managment"); 
    $mail->Send(); 

    if(!$mail->Send()) { 
     echo "Mailer Error: " . $mail->ErrorInfo; 
    } else { 
     echo "Message sent!"; 
    } 

} 

問題是,它無視20mb的大小限制,並且不允許用戶上傳大於1.something mb的文件。

任何幫助將不勝感激。

這是我目前的php.ini:

register_globals = Off 

post_max_size = 20M 
upload_max_filesize = 20M 


[Zend] 

zend_optimizer.optimization_level=15 

zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-2.5.10 

zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-2.5.10 

zend_optimizer.version=2.5.10a 

zend_extension = /usr/local/lib/ioncube_loader_lin_4.4.so 



zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so 

zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so 
+0

@XGreen:你在使用什麼web服務器?例如,apache和nginx具有最大POST大小的配置設置。 – ngoozeff 2010-08-10 14:33:18

+0

我使用Apache從HOSTPAPA加拿大提供商。在php配置部分的域中,CPANEL表示:文件上傳\t upload_max_filesize \t上傳文件的最大允許大小。 \t 64M – XGreen 2010-08-10 14:35:19

+0

如何更改最大發布大小的配置設置?我是否需要將.htaccess添加到項目根目錄?什麼是我需要寫的正確語法? – XGreen 2010-08-10 14:39:07

回答

2

你可以嘗試訂閱您的通話uploadify的onError的處理程序。像這樣,在onAllComplete處理程序之後...

onError: function (a, b, c, d) { 
    if (d.status == 404) 
     alert('Could not find upload script.'); 
    else if (d.type === "HTTP") 
     alert('error '+d.type+": "+d.status); 
    else if (d.type ==="File Size") 
     alert(c.name+' '+d.type+' Limit: '+Math.round(d.sizeLimit/1024)+'KB'); 
    else 
     alert('error '+d.type+": "+d.text); 
} 
+0

謝謝,雖然'd.sizeLimit'沒有定義 – jfoucher 2011-08-16 21:32:11

0

這可能是一個或多個PHP設置的問題。見我的回答類似的問題:

Change file upload size in linux server

+0

同時添加 php_value的upload_max_filesize 70M php_value的post_max_size 80M php_value memory_limit的90M php_value的max_execution_time 240 php_value max_input_time設置240 到我的.htaccess而不是以前的指令。它不會崩潰但不起作用。 – XGreen 2010-08-10 16:36:11

+0

在htacess中使用upload_max_filesize導致我的服務器崩潰 – XGreen 2010-08-10 17:32:18

+0

是否有可能php_value命令被我的提供者禁止? – XGreen 2010-08-10 18:49:37