15 require
'../../_src/_config.php';
21 logWrite(
'chiamata API file',
'uploader', LOG_DEBUG );
27 $fileName = $_SERVER[
'HTTP_X_FILE_NAME'];
28 $fileSize = $_SERVER[
'HTTP_X_FILE_SIZE'];
29 $chunkNumber = $_SERVER[
'HTTP_X_CHUNK_NUMBER'];
30 $totalChunks = $_SERVER[
'HTTP_X_CHUNK_TOTAL'];
33 logWrite(
'inizio caricamento file: ' . $fileName .
' chunk ' . $chunkNumber .
'/' . $totalChunks,
'uploader', LOG_NOTICE );
36 $collisionCounter = 0;
37 $targetFolder = ( isset( $_SERVER[
'HTTP_X_TARGET_FOLDER'] ) ) ? $_SERVER[
'HTTP_X_TARGET_FOLDER'] :
'tmp/';
46 $targetFileRelativePath = $targetRelativePath . $fileName;
47 $targetFileAbsolutePath = $targetFolder . $fileName;
49 if( file_exists( $targetFileRelativePath ) ) {
53 $arrayNomeFile = explode(
'.', $fileName );
54 $estensione = array_pop( $arrayNomeFile );
55 $arrayNomeFile[] = $collisionCounter;
56 $arrayNomeFile[] = $estensione;
57 $fileName = implode(
'.', $arrayNomeFile );
67 }
while( $collision ==
true );
70 $estensioneChunk =
'.part' . sprintf(
'%04d' , $chunkNumber );
71 $targetFileRelativePathWithChunk = $targetFileRelativePath . $estensioneChunk;
74 $input = fopen(
'php://input' ,
'r' );
75 $output = fopen( $targetFileRelativePathWithChunk ,
'w' );
78 while( $data = fread(
$input, 1024 ) ) {
79 fwrite( $output, $data );
87 $writeData = filesize( $targetFileRelativePathWithChunk );
90 if( $chunkNumber == $totalChunks ) {
93 $arrayChunks = glob( $targetFileRelativePath .
'.part*' );
96 $h = fopen( $targetFileRelativePath ,
"ab" );
99 foreach( $arrayChunks as $chunk ) {
102 $in = fopen( $chunk ,
"rb" );
105 while( $buff = fread( $in, 1048576 ) ) {
106 fwrite(
$h , $buff );
122 $reply[
'fileSize'] = $fileSize;
123 $reply[
'writtenData'] = $writeData;
124 $reply[
'fileUrl'] =
$cf[
'site'][
'url'].$targetFileAbsolutePath;
125 $reply[
'filePath'] = $targetFileAbsolutePath;
logWrite( $m, $f='site', $l=LOG_NOTICE, $d=DIRECTORY_LOG, $t=CURRENT_LOG_LEVEL, $s=SITE_STATUS)
scrive un messaggio nei log del sito
$cf['ricerca']['template']