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