Feature #4856 check if there is avalaible enought space in course folder

skala
Juan Carlos Raña 14 years ago
parent 2212cb94d1
commit f95ca5ff41
  1. 19
      main/inc/lib/jpegcam/webcam_receiver.php

@ -75,13 +75,28 @@ if (!$content) {
exit();
}
//make a temporal file for get the file size
$tmpfname = tempnam("/tmp", "CTF");
$handle = fopen($tmpfname, "w");
fwrite($handle, $content);
fclose($handle);
// Check if there is enough space in the course to save the file
if (!DocumentManager::enough_space(filesize($tmpfname), DocumentManager::get_course_quota())) {
unlink($tmpfname);
die(get_lang('UplNotEnoughSpace'));
}
//erase temporal file
unlink($tmpfname);
//add to disk
$fh = fopen($documentPath, 'w') or die("can't open file");
fwrite($fh, $content);
fclose($fh);
//
//add document to database
$doc_id = add_document($_course, $webcamdir.'/'.$webcamname_to_save, 'file', filesize($documentPath), $title_to_save);
api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id);

Loading…
Cancel
Save