2015-06-15 47 views
0

我需要一個CMS爲使漫畫的讀者,所以我買了PHP漫畫:http://codecanyon.net/item/php-manga-manga-reader-website-solution/full_screen_preview/10102963腳本上傳圖片不能正常工作

的問題是,漫畫圖像不是爲了上傳。例如,如果我選擇並上傳圖像(或頁面)1,2,3 ...,他會上傳3,1,2等圖像。

不幸的是,他們不再提供支持,當我決定購買它時,我並不知道,因爲我無法在沒有許可證的情況下訪問他們的論壇。所以我需要自己解決這個問題。

這是輸入形式:

<?php echo Form::input('uploaderInput', R('uploaderInput'), array("type"=>"file", "data-href"=>URL('admin/base64'), "data-dir"=>"upload/manga/".$thisManga['slug']."/", "id"=>"inputUploader", "class"=>"form-control ", "multiple")) ?> 

這是模板

$template->customJs .= '$("#chapterNumber").on("keyup", function(){ 
          $("#chapterInfoDiv").show(); 
         }); 


         function readImage(input) { 
          for(var i=0,file; file = input.files[i]; i++) { 
           var FR = new FileReader(); 
           FR.onload = function(e) { 
            var base64 = e.target.result, 
             h = $("#inputUploader").data("href"), 
             d = $("#inputUploader").data("dir")+$("#chapterNumber").val(), 
             options = { 
              type: "POST", 
              url: h, 
              data: { base64 : base64 , dir : d }, 
              dataType: "json", 
              success: function(response) { 
               if(response.s == "ko"){ 
                alert(response.m); 
               }else if(response.s == "ok"){ 
                $("textarea#inputContent").val($("textarea#inputContent").val()+""+response.m+";"); 
               } 
              } 
             }; 
             $.ajax(options); 
           };  
           FR.readAsDataURL(input.files[i]); 
          } 
         } 

         $("#inputUploader").change(function(){ 
          readImage(this); 
         }); 

         '; 

這是函數

function secure_img_upload($file, $path, $options = array()){ 
// HANDLE OPTIONS 
$validExtensions = isset($options['validExtensions']) ? $options['validExtensions'] : array('jpg', 'jpeg', 'png'); 
$surfix = isset($options['surfix']) ? $options['surfix'] : ''; 

// HANDLES FILES 
$tempFile   = $file['tmp_name']; 
$fileName   = $file['name']; 
$extension = explode(".", $fileName); 
$extension = strtolower(end($extension)); 
$imageName  = sha1($fileName.uniqid()); 
$destination = rtrim($path, '/').'/'.$imageName.$surfix.'.'.$extension; 

if(in_array($extension, $validExtensions)) { 
    $validExtension  = true;  
} else { 
    $validExtension  = false;  
} 

// Run getImageSize function to check that we're really getting an image 
if(getimagesize($tempFile) == false) { 
    $validImage  = false;  
} else { 
    $validImage  = true;  
} 

if($validExtension == true && $validImage == true) { 
    if(move_uploaded_file($tempFile, $destination)) { 
     return $destination; 
    }else{ 
     return array('s'=>'ko', 'm'=>T("Invalid path.")); 
    } 
    }else{ 
    return array('s'=>'ko', 'm'=>T("Invalid extension.")); 
    } 

能否請你幫我解決這個問題?真的,我找不到任何錯誤的...上傳者爲多

回答

1

單個輸入有一個插件來解決它
codecanyon.net/item/jqupload-plugin-for-php-manga/12098507
該插件將修復訂單並顯示上傳進度(速度,字節數)。完整的細節可以在codecanyon上看到