Greetings gentlemen,
I got the following problem:
If I upload a file, the uploaded file is imcomplete,
e.g I upload a 416 kb .csv file with ~3000 lines and the uploaded file is only 235 lines long.
The servers settings are fine (memory limit, max_post_size, max_uplaod_size)
here's some code:
whole Upload.php:
Code
<?php
/*
* Name: PHP: upload
*
* Description:
* - handles the uploaded .csv file which was sent by the frontend. </br>
* - starts the session, the session id defines the filename of the .csv </br>
* - executes function preprocess (PHP: preprocessing methods) </br>
* - executes function initOptions (PHP: initOptions methods) </br>
* - executes start (PHP: Server Class) </br>
* - executes printData (PHP: Options Class)
*/
// to show php errors..
error_reporting(E_ALL);
ini_set('display_errors', 'On');
include_once("preprocessing.php");
include_once("initOptions.php");
include_once("searchOptions.php");
include_once("config.php");
include_once("server.php");
$output_dir = $PATH_TO_WEBAPP . "/uploads/";
if(isset($_FILES["file"])) {
@session_start();
if ($_FILES["file"]["error"] > 0) {
echo "Error: " . $_FILES["file"]["error"] . "<br>";
}
else {
//move the uploaded file to uploads folder;
move_uploaded_file($_FILES["file"]["tmp_name"], $output_dir. session_id().".csv.orig");
}
$_SESSION["shared"] = false;
$_SESSION["db"] = session_id();
$filename = $output_dir. session_id().".csv.orig";
preprocess($filename);
initOptions();
Server::start();
Options::printData();
}
return;
?>
javascript snippet:
it is using this upload script:
https://github.com/michaelcbrook/simpleUpload.jsCode
$(document).on('change', '.btn-file :file', function() {
var input = $(this),
numFiles = input.get(0).files ? input.get(0).files.length : 1,
label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
input.trigger('fileselect', [numFiles, label]);
input.simpleUpload("php/upload.php", {
start: function() {
var button1 = input.parents('.btn-file').find('.txt-bfr-upld');
var button2 = input.parents('.btn-file').find('.txt-aft-upld');
button1.toggleClass("hide");
button2.toggleClass("hide");
},
progress: function(progress) {
//received progress
$('.btn-progress').text("Progress: " + Math.round(progress) + "%");
},
success: function(data){
//upload successful
$('.btn-progress').text("Success!");
$('.view-bfr-upld').toggleClass('hide')
$('.view-aft-upld').toggleClass('hide')
updateAllBoxes("", 5);
createCheckboxes(data);
shared = false;
$('#settings > span').css("opacity", "1");
$('#settings > span').removeAttr("title");
},
});
});
anyone got an Idea why this happens?
thx in advance