douchenchepan6465 2015-06-15 22:11
浏览 47
已采纳

上传图片的脚本不起作用

I need a CMS for make a Manga reader, so I bought PHP Manga: http://codecanyon.net/item/php-manga-manga-reader-website-solution/full_screen_preview/10102963

The problem is that manga images are not uploaded in order. For example, If I select and upload images (or pages) 1, 2, 3... He upload the images in 3,1,2 or so on.

Sadly they doesn't offer support anymore, and when I decided to buy it I didn't knew since I was unable to access to their forum without a license. So I need to fix this problem on my own.

This is the input form:

<?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")) ?>

this is the template

$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 );
                        });

                        ';

This is the function

    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."));
    }

Can you please help me to fix this problem? Really, I can't find anything wrong... The uploader is a single input with multi

  • 写回答

1条回答 默认 最新

  • duanpo1821 2015-11-09 04:58
    关注

    there are a plugin to fix it
    check it on codecanyon
    That plugin will fix the order and showing the upload progress(speed,number of byte). The full detail can see on codecanyon

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了