コード例 #1
0
ファイル: multi_upload.php プロジェクト: helenadeus/s3db.map
                }
            }
            echo $msg;
        }
    }
    #if there is no data besides the key, ask for a filename and filesize
    #if($filename == '') $filename = $xml -> filename;
    #$filesize = $_REQUEST['filesize'];
    #if($filesize == '') $filesize = $xml -> filesize;
    ##Copy file from Php tmp directory
} else {
    $filekey = $xml->filekey;
    if ($filekey == '') {
        $filekey = $_REQUEST['filekey'];
    }
    if ($filekey != '') {
        include_once 'core.filekeyheader.php';
        #add a form to the page such that it accepts both POST and GET
        #echo '<form name="file" method="POST">';
        #echo '<input type="hidden" name="query"> <!-- this form is for programming environments that support sending POST -->';
        #echo '</form>';
        #echo receiveFileFragments(compact('filekey', 'db'));
        echo formatReturn('0', receiveFileFragments(compact('filekey', 'db')), $format, '');
        exit;
    } else {
        include_once S3DB_SERVER_ROOT . '/s3dbcore/callback.php';
        include_once S3DB_SERVER_ROOT . '/s3dbcore/display.php';
        echo formatReturn('3', "Filekey is missing.", $format, '');
        exit;
    }
}
コード例 #2
0
ファイル: move2s3db.php プロジェクト: helenadeus/s3db.map
function move2s3db($toMove, $db, $user_id)
{
    #toMove is an array with file, item_id and rule_id, for example $toMove=compact('file','item_id','rule_id');
    ##
    #encode the file in base64. Break it in 1084 (1Mb) pieces
    $fid = fopen($toMove['file'], 'r');
    #$fSize = 10000;
    $fSize = filesize($toMove['file']);
    ##=>to change once I find a way to palce the pointer at the end of the file
    $parts = ceil(filesize($toMove['file']) / $fSize);
    $filekey = generateAFilekey(array('filename' => $toMove['file'], 'filesize' => filesize($toMove['file']), 'db' => $db, 'user_id' => $user_id));
    for ($i = 1; $i <= $parts; $i++) {
        $fileStr = base64_encode(fread($fid, $fSize));
        $fragNr = $i . '/' . $parts;
        #echo "sending frag ".$fragNr.chr(10);
        ###
        #send this piece to the local deployment as a file
        if ($fileStr != '') {
            $received = receiveFileFragments(compact('filekey', 'db', 'fileStr', 'fragNr'));
        }
    }
    $s3ql = compact('user_id', 'db');
    $s3ql['insert'] = 'file';
    $s3ql['where']['filekey'] = $filekey;
    $s3ql['where']['rule_id'] = $toMove['rule_id'];
    $s3ql['where']['item_id'] = $toMove['item_id'];
    $fileinserted = S3QLaction($s3ql);
    $fileinserted = html2cell($fileinserted);
    return $fileinserted;
}