/sprout/config/routes.php Highlighted file source
Line 63: $config['admin/import_upload/([^/]+)'] = 'AdminController/importUpload/$1';
Line 64: $config['admin/import_upload_action/([^/]+)'] = 'AdminController/importUploadAction/$1';
Line 123: $config['tinymce4/upload'] = 'Tinymce4Controller/upload';
Line 144: $config['file_upload/upload_begin'] = 'Sprout\\Controllers\\FileUploadController/uploadBegin';
Line 145: $config['file_upload/upload_chunk'] = 'Sprout\\Controllers\\FileUploadController/uploadChunk';
Line 146: $config['file_upload/upload_done'] = 'Sprout\\Controllers\\FileUploadController/uploadDone';
Line 147: $config['file_upload/upload_form'] = 'Sprout\\Controllers\\FileUploadController/uploadForm';
Line 148: $config['file_upload/upload_cancel'] = 'Sprout\\Controllers\\FileUploadController/uploadCancel';
/sprout/config/routes.php Highlighted file source
Line 63: $config['admin/import_upload/([^/]+)'] = 'AdminController/importUpload/$1';
Line 64: $config['admin/import_upload_action/([^/]+)'] = 'AdminController/importUploadAction/$1';
Line 123: $config['tinymce4/upload'] = 'Tinymce4Controller/upload';
Line 144: $config['file_upload/upload_begin'] = 'Sprout\\Controllers\\FileUploadController/uploadBegin';
Line 145: $config['file_upload/upload_chunk'] = 'Sprout\\Controllers\\FileUploadController/uploadChunk';
Line 146: $config['file_upload/upload_done'] = 'Sprout\\Controllers\\FileUploadController/uploadDone';
Line 147: $config['file_upload/upload_form'] = 'Sprout\\Controllers\\FileUploadController/uploadForm';
Line 148: $config['file_upload/upload_cancel'] = 'Sprout\\Controllers\\FileUploadController/uploadCancel';
/sprout/Controllers/Admin/FileAdminController.php Highlighted file source
Line 35: use Sprout\Helpers\FileUpload;
Line 50: use Sprout\Helpers\Upload;
Line 160: * Save a single chunk of a multi-part file upload
Line 164: * @post string code Unique code for this upload
Line 194: * Stitch together uploaded chunks into an actual file
Line 201: * @post num The total number of chunks uploaded
Line 202: * @post string code Unique code for this upload
Line 214: $dest_filename = 'upload-' . time() . '-' . $_POST['code'] . '.dat';
Line 229: * Stitch together the uploaded file from multiple chunks
Line 232: * @param string $code Upload code
Line 289: * Returns the form for updating a file which has been uploaded
Line 300: if (!FileUpload::checkFilename($_GET['file']['name'])) {
Line 301: echo '<p>This type of file cannot be uploaded.</p>';
Line 373: * Handles the drag-and-drop upload form
Line 389: if (!FileUpload::checkFilename($_POST['orig_name'])) {
Line 390: Json::error('This type of file cannot be uploaded');
Line 440: // Filename is only set after upload because the ID is in the name
Line 471: $result = File::moveUpload($src, $filename);
Line 475: $result = File::moveUpload($src, $filename);
Line 483: File::postUploadProcessing($filename, $file_id, $type);
Line 490: $html = '<div class="file-upload__item__feedback__response file-upload__item__feedback__response--success file-upload__item__feedback__response--success--not-image">';
Line 491: $html .= '<p class="file-upload__item__feedback__name"><a href="admin/edit/file/' . $file_id . '" target="_blank">' . Enc::html($filename) . '</a></p>';
Line 492: $html .= '<p class="file-upload__item__feedback__size">' . File::humanSize(File::size($filename)) . '</p>';
Line 504: * Cancel an upload - delete temporary files.
Line 507: * [result][tmp_file] Whole file was uploaded
Line 508: * [partial_upload][code] Only some chunks of the file have been uploaded
Line 514: // The file upload controller has a perfect implementation of this, so just use that
Line 515: $ctlr = new \Sprout\Controllers\FileUploadController();
Line 516: $ctlr->uploadCancel();
Line 566: * Does a quick upload (from the fileselector)
Line 569: public function quickUpload()
Line 577: $result = $this->doUpload(@$_POST['category_id']);
Line 584: * Used by the quick upload tool
Line 587: private function doUpload($category_id)
Line 591: // Check upload exists and has valid metadata
Line 597: $temp_file = FileUpload::verify('admin_quick_upload', 'file', 0, $allowed_exts);
Line 600: return ['error' => 'File uploading failed'];
Line 609: if (!FileUpload::checkFilename($filename)) {
Line 610: return array('error' => 'This type of file cannot be uploaded');
Line 647: return array('error' => 'Unable to upload file; database error (main)');
Line 658: return array('error' => 'Unable to upload file; database error (cat)');
Line 667: return array('error' => 'Unable to upload file; database error (joiner)');
Line 671: // Upload the file - uses the file id
Line 673: $result = File::moveUpload($temp_file, $filename);
Line 675: return array('error' => 'Failed to save the uploaded file in media repository');
Line 680: File::postUploadProcessing($filename, $file_id, $file_type);
Line 779: // Check upload is valid
Line 780: if (!Upload::valid($_FILES['replace'])) {
Line 781: Notification::error('Error with upload of replacement; you will need to re-select your file');
Line 782: $valid->addFieldError('replace', 'File upload failed');
Line 788: Notification::error('Error with file upload; you will need to re-select your file');
Line 801: // Upload the new file
Line 808: Notification::error('File upload failed');
Line 827: Notification::confirm('New file uploaded successfully');
Line 1363: $view->upload = isset($_GET['upload']) ? (int) $_GET['upload'] : 1;
Line 1368: $view->upload = false;
Line 1576: * Provide the contents of a temporarily uploaded file, for e.g. listening to uploaded audio
/sprout/Controllers/Admin/FileAdminController.php Highlighted file source
Line 35: use Sprout\Helpers\FileUpload;
Line 50: use Sprout\Helpers\Upload;
Line 160: * Save a single chunk of a multi-part file upload
Line 164: * @post string code Unique code for this upload
Line 194: * Stitch together uploaded chunks into an actual file
Line 201: * @post num The total number of chunks uploaded
Line 202: * @post string code Unique code for this upload
Line 214: $dest_filename = 'upload-' . time() . '-' . $_POST['code'] . '.dat';
Line 229: * Stitch together the uploaded file from multiple chunks
Line 232: * @param string $code Upload code
Line 289: * Returns the form for updating a file which has been uploaded
Line 300: if (!FileUpload::checkFilename($_GET['file']['name'])) {
Line 301: echo '<p>This type of file cannot be uploaded.</p>';
Line 373: * Handles the drag-and-drop upload form
Line 389: if (!FileUpload::checkFilename($_POST['orig_name'])) {
Line 390: Json::error('This type of file cannot be uploaded');
Line 440: // Filename is only set after upload because the ID is in the name
Line 471: $result = File::moveUpload($src, $filename);
Line 475: $result = File::moveUpload($src, $filename);
Line 483: File::postUploadProcessing($filename, $file_id, $type);
Line 490: $html = '<div class="file-upload__item__feedback__response file-upload__item__feedback__response--success file-upload__item__feedback__response--success--not-image">';
Line 491: $html .= '<p class="file-upload__item__feedback__name"><a href="admin/edit/file/' . $file_id . '" target="_blank">' . Enc::html($filename) . '</a></p>';
Line 492: $html .= '<p class="file-upload__item__feedback__size">' . File::humanSize(File::size($filename)) . '</p>';
Line 504: * Cancel an upload - delete temporary files.
Line 507: * [result][tmp_file] Whole file was uploaded
Line 508: * [partial_upload][code] Only some chunks of the file have been uploaded
Line 514: // The file upload controller has a perfect implementation of this, so just use that
Line 515: $ctlr = new \Sprout\Controllers\FileUploadController();
Line 516: $ctlr->uploadCancel();
Line 566: * Does a quick upload (from the fileselector)
Line 569: public function quickUpload()
Line 577: $result = $this->doUpload(@$_POST['category_id']);
Line 584: * Used by the quick upload tool
Line 587: private function doUpload($category_id)
Line 591: // Check upload exists and has valid metadata
Line 597: $temp_file = FileUpload::verify('admin_quick_upload', 'file', 0, $allowed_exts);
Line 600: return ['error' => 'File uploading failed'];
Line 609: if (!FileUpload::checkFilename($filename)) {
Line 610: return array('error' => 'This type of file cannot be uploaded');
Line 647: return array('error' => 'Unable to upload file; database error (main)');
Line 658: return array('error' => 'Unable to upload file; database error (cat)');
Line 667: return array('error' => 'Unable to upload file; database error (joiner)');
Line 671: // Upload the file - uses the file id
Line 673: $result = File::moveUpload($temp_file, $filename);
Line 675: return array('error' => 'Failed to save the uploaded file in media repository');
Line 680: File::postUploadProcessing($filename, $file_id, $file_type);
Line 779: // Check upload is valid
Line 780: if (!Upload::valid($_FILES['replace'])) {
Line 781: Notification::error('Error with upload of replacement; you will need to re-select your file');
Line 782: $valid->addFieldError('replace', 'File upload failed');
Line 788: Notification::error('Error with file upload; you will need to re-select your file');
Line 801: // Upload the new file
Line 808: Notification::error('File upload failed');
Line 827: Notification::confirm('New file uploaded successfully');
Line 1363: $view->upload = isset($_GET['upload']) ? (int) $_GET['upload'] : 1;
Line 1368: $view->upload = false;
Line 1576: * Provide the contents of a temporarily uploaded file, for e.g. listening to uploaded audio
/sprout/Controllers/Admin/PageAdminController.php Highlighted file source
Line 41: use Sprout\Helpers\FileUpload;
Line 65: use Sprout\Helpers\Upload;
Line 449: * Return HTML for the import upload form
Line 451: public function _importUploadForm()
Line 463: $view = new View('sprout/admin/page_import_upload');
Line 471: * Upload and do initial processing on the file
Line 473: public function importUploadAction()
Line 479: // Validate upload
Line 482: } else if (! Upload::required($_FILES['import'])) {
Line 484: } else if (! Upload::valid($_FILES['import'])) {
Line 485: $error = 'File upload error';
Line 486: } else if (! FileUpload::checkFilename($_FILES['import']['name'])) {
Line 502: // Upload file to temp dir
Line 562: Url::redirect("admin/import_upload/page");
Line 809: $update_fields['changes_made'] = 'Imported page from uploaded file';
Line 830: $res = $this->addHistoryItem($page_id, "Imported page from uploaded file");
Line 2462: $items[] = "<li class=\"import\"><a href=\"SITE/admin/import_upload/page\">Document import</a></li>";
/sprout/Controllers/Admin/PageAdminController.php Highlighted file source
Line 41: use Sprout\Helpers\FileUpload;
Line 65: use Sprout\Helpers\Upload;
Line 449: * Return HTML for the import upload form
Line 451: public function _importUploadForm()
Line 463: $view = new View('sprout/admin/page_import_upload');
Line 471: * Upload and do initial processing on the file
Line 473: public function importUploadAction()
Line 479: // Validate upload
Line 482: } else if (! Upload::required($_FILES['import'])) {
Line 484: } else if (! Upload::valid($_FILES['import'])) {
Line 485: $error = 'File upload error';
Line 486: } else if (! FileUpload::checkFilename($_FILES['import']['name'])) {
Line 502: // Upload file to temp dir
Line 562: Url::redirect("admin/import_upload/page");
Line 809: $update_fields['changes_made'] = 'Imported page from uploaded file';
Line 830: $res = $this->addHistoryItem($page_id, "Imported page from uploaded file");
Line 2462: $items[] = "<li class=\"import\"><a href=\"SITE/admin/import_upload/page\">Document import</a></li>";
/sprout/Controllers/AdminController.php Highlighted file source
Line 58: use Sprout\Helpers\Upload;
Line 609: * File upload box for importing, options are the next step
Line 613: public function importUpload($type)
Line 628: $main = $ctlr->_importUploadForm();
Line 632: $main = new View('sprout/admin/import_upload');
Line 647: public function importUploadAction($type)
Line 657: // validate upload
Line 659: if (! Upload::required($_FILES['import'])) {
Line 661: } else if (! Upload::valid($_FILES['import'])) {
Line 662: $error = 'File upload error';
Line 663: } else if (! Upload::type($_FILES['import'], $formats)) {
Line 697: Url::redirect("admin/import_upload/{$type}");
Line 719: $this->error("Uploaded import file not found on server");
Line 764: $this->error("Uploaded import file not found on server");
/sprout/Controllers/AdminController.php Highlighted file source
Line 58: use Sprout\Helpers\Upload;
Line 609: * File upload box for importing, options are the next step
Line 613: public function importUpload($type)
Line 628: $main = $ctlr->_importUploadForm();
Line 632: $main = new View('sprout/admin/import_upload');
Line 647: public function importUploadAction($type)
Line 657: // validate upload
Line 659: if (! Upload::required($_FILES['import'])) {
Line 661: } else if (! Upload::valid($_FILES['import'])) {
Line 662: $error = 'File upload error';
Line 663: } else if (! Upload::type($_FILES['import'], $formats)) {
Line 697: Url::redirect("admin/import_upload/{$type}");
Line 719: $this->error("Uploaded import file not found on server");
Line 764: $this->error("Uploaded import file not found on server");
/sprout/Controllers/DbToolsController.php Highlighted file source
Line 45: use Sprout\Helpers\FileUpload;
Line 780: echo Form::upload('filename');
Line 781: echo '<div class="action-bar"><button type="submit" class="button icon-after icon-file_upload">Upload file</button></div>';
Line 821: echo '<p>Uploaded file: <code>', Enc::html($_GET['tempname']), '</code></p>';
Line 1242: echo Form::upload('filename');
Line 1243: echo '<div class="action-bar"><button type="submit" class="button icon-after icon-file_upload">Import files</button></div>';
Line 1261: if (empty($_FILES['filename']) or $_FILES['filename']['error'] !== UPLOAD_ERR_OK) {
Line 1262: Notification::error('There was an error uploading your file, please try again.');
Line 1280: if (!FileUpload::checkFilename($filename)) {
Line 1908: $view = new View('sprout/dbtools/module_builder_existing_upload');
Line 1920: public function moduleBuilderExistingUploadAction()
Line 1925: // Upload a new file
Line 2907: // Attempt upload
/sprout/Controllers/DbToolsController.php Highlighted file source
Line 45: use Sprout\Helpers\FileUpload;
Line 780: echo Form::upload('filename');
Line 781: echo '<div class="action-bar"><button type="submit" class="button icon-after icon-file_upload">Upload file</button></div>';
Line 821: echo '<p>Uploaded file: <code>', Enc::html($_GET['tempname']), '</code></p>';
Line 1242: echo Form::upload('filename');
Line 1243: echo '<div class="action-bar"><button type="submit" class="button icon-after icon-file_upload">Import files</button></div>';
Line 1261: if (empty($_FILES['filename']) or $_FILES['filename']['error'] !== UPLOAD_ERR_OK) {
Line 1262: Notification::error('There was an error uploading your file, please try again.');
Line 1280: if (!FileUpload::checkFilename($filename)) {
Line 1908: $view = new View('sprout/dbtools/module_builder_existing_upload');
Line 1920: public function moduleBuilderExistingUploadAction()
Line 1925: // Upload a new file
Line 2907: // Attempt upload
/sprout/Controllers/FileUploadController.php Highlighted file source
Line 18: use Sprout\Exceptions\FileUploadException;
Line 22: use Sprout\Helpers\FileUpload;
Line 29: * Handles file uploads in chunks using the JS File API and XMLHttpRequest
Line 31: class FileUploadController extends Controller
Line 34: * Maximum number of chunks that can be uploaded per field-session
Line 55: * Creates a session record for a new file upload, and configures its initial state
Line 76: if (isset($_SESSION['file_uploads'][$uri][$field_name][$code])) {
Line 80: if (!isset($_SESSION['file_uploads'][$uri][$field_name])) {
Line 81: $_SESSION['file_uploads'][$uri][$field_name] = [];
Line 84: $_SESSION['file_uploads'][$uri][$field_name][$code] = [
Line 89: return $_SESSION['file_uploads'][$uri][$field_name][$code];
Line 94: * Gets the session data associated with a file upload
Line 113: if (!isset($_SESSION['file_uploads'][$uri][$field_name][$code])) {
Line 117: return $_SESSION['file_uploads'][$uri][$field_name][$code];
Line 129: unset($_SESSION['file_uploads'][$uri][$field_name][$code]);
Line 131: if (empty($_SESSION['file_uploads'][$uri][$field_name])) {
Line 132: unset($_SESSION['file_uploads'][$uri][$field_name]);
Line 138: * Signals that the user would like to upload a file
Line 140: * @post string code Their upload code
Line 144: public function uploadBegin()
Line 153: * Perform additional checks (beyond the checks already in {@see FileUploadController::uploadChunk}) on an uploaded chunk.
Line 163: * Perform a size check on a set of uploaded chunks.
Line 173: * Perform a size check on a completed upload (after chunks have been stitched).
Line 175: * @param string $temp_path Path to the temporary uploaded file
Line 176: * @throws FileUploadException if the file is smaller than the allowed maximum for the field.
Line 186: * @throws FileUploadException if the file extension is matches the requirements for the field.
Line 194: throw new FileUploadException("File type doesn't match extension");
Line 200: * Save a single chunk of a multi-part file upload
Line 204: * @post string code Unique code for this upload
Line 207: public function uploadChunk()
Line 209: $upload_state = &$this->session();
Line 219: // Ensure a file chunk was actually uploaded
Line 220: if (empty($_FILES['chunk']) or $_FILES['chunk']['error'] !== UPLOAD_ERR_OK) {
Line 221: Json::error('Error uploading chunk');
Line 224: // Check that there's actually content behind their upload
Line 226: Json::error('The uploaded file chunk was empty, there may have been a network fault during your upload');
Line 238: if (!$upload_state) {
Line 239: // @see uploadBegin
Line 240: Json::error('File upload wasn\'t started correctly');
Line 243: $upload_state['size'] += $_FILES['chunk']['size'];
Line 247: if ($_POST['index'] < 0 or $upload_state['index'] !== $_POST['index']) {
Line 254: static::cleanupChunks($upload_state['code'], $upload_state['index']);
Line 256: Json::error('Maximum number of upload chunks exceeded');
Line 259: $upload_state['index'] = $_POST['index'] + 1;
Line 262: $result = move_uploaded_file($_FILES['chunk']['tmp_name'], $filename);
Line 272: * Stitch together uploaded chunks into an actual file
Line 279: * @post num The total number of chunks uploaded
Line 280: * @post string code Unique code for this upload
Line 283: public function uploadDone()
Line 285: $upload_state = &$this->session();
Line 292: if ($upload_state['index'] !== $_POST['num']) {
Line 293: Json::error('Invalid number of chunks uploaded');
Line 296: $dest_filename = 'upload-' . time() . '-' . $_POST['code'] . '.dat';
Line 301: if ($total_size !== $upload_state['size']) {
Line 302: Json::error('Final filesize didn\'t match upload size');
Line 315: * Returns the form for updating a file which has been uploaded
Line 322: public function uploadForm()
Line 330: if (!FileUpload::checkFilename($_GET['file']['name'])) {
Line 331: $error = 'This type of file cannot be uploaded';
Line 337: } catch (FileUploadException $ex) {
Line 345: } catch (FileUploadException $ex) {
Line 384: * Stitch together the uploaded file from multiple chunks
Line 387: * @param string $code Upload code
Line 446: * @param string $code The upload session code
Line 460: * Cancel an upload - delete temporary files.
Line 463: * [result][tmp_file] Whole file was uploaded
Line 464: * [partial_upload][code] Only some chunks of the file have been uploaded
Line 468: public function uploadCancel()
Line 471: // Whole file was uploaded
Line 472: $result = preg_match('/^upload-[0-9]+-[a-zA-Z0-9]{32}.dat$/', $_POST['result']['tmp_file']);
Line 479: } elseif (isset($_POST['partial_upload']['code'])) {
Line 480: // Only part of the file has been uploaded
Line 481: $result = preg_match('/^[a-zA-Z0-9]{32}$/', $_POST['partial_upload']['code']);
Line 486: $files = glob(APPPATH . 'temp/chunk-' . $_POST['partial_upload']['code'] . '-*.dat');
/sprout/Controllers/FileUploadController.php Highlighted file source
Line 18: use Sprout\Exceptions\FileUploadException;
Line 22: use Sprout\Helpers\FileUpload;
Line 29: * Handles file uploads in chunks using the JS File API and XMLHttpRequest
Line 31: class FileUploadController extends Controller
Line 34: * Maximum number of chunks that can be uploaded per field-session
Line 55: * Creates a session record for a new file upload, and configures its initial state
Line 76: if (isset($_SESSION['file_uploads'][$uri][$field_name][$code])) {
Line 80: if (!isset($_SESSION['file_uploads'][$uri][$field_name])) {
Line 81: $_SESSION['file_uploads'][$uri][$field_name] = [];
Line 84: $_SESSION['file_uploads'][$uri][$field_name][$code] = [
Line 89: return $_SESSION['file_uploads'][$uri][$field_name][$code];
Line 94: * Gets the session data associated with a file upload
Line 113: if (!isset($_SESSION['file_uploads'][$uri][$field_name][$code])) {
Line 117: return $_SESSION['file_uploads'][$uri][$field_name][$code];
Line 129: unset($_SESSION['file_uploads'][$uri][$field_name][$code]);
Line 131: if (empty($_SESSION['file_uploads'][$uri][$field_name])) {
Line 132: unset($_SESSION['file_uploads'][$uri][$field_name]);
Line 138: * Signals that the user would like to upload a file
Line 140: * @post string code Their upload code
Line 144: public function uploadBegin()
Line 153: * Perform additional checks (beyond the checks already in {@see FileUploadController::uploadChunk}) on an uploaded chunk.
Line 163: * Perform a size check on a set of uploaded chunks.
Line 173: * Perform a size check on a completed upload (after chunks have been stitched).
Line 175: * @param string $temp_path Path to the temporary uploaded file
Line 176: * @throws FileUploadException if the file is smaller than the allowed maximum for the field.
Line 186: * @throws FileUploadException if the file extension is matches the requirements for the field.
Line 194: throw new FileUploadException("File type doesn't match extension");
Line 200: * Save a single chunk of a multi-part file upload
Line 204: * @post string code Unique code for this upload
Line 207: public function uploadChunk()
Line 209: $upload_state = &$this->session();
Line 219: // Ensure a file chunk was actually uploaded
Line 220: if (empty($_FILES['chunk']) or $_FILES['chunk']['error'] !== UPLOAD_ERR_OK) {
Line 221: Json::error('Error uploading chunk');
Line 224: // Check that there's actually content behind their upload
Line 226: Json::error('The uploaded file chunk was empty, there may have been a network fault during your upload');
Line 238: if (!$upload_state) {
Line 239: // @see uploadBegin
Line 240: Json::error('File upload wasn\'t started correctly');
Line 243: $upload_state['size'] += $_FILES['chunk']['size'];
Line 247: if ($_POST['index'] < 0 or $upload_state['index'] !== $_POST['index']) {
Line 254: static::cleanupChunks($upload_state['code'], $upload_state['index']);
Line 256: Json::error('Maximum number of upload chunks exceeded');
Line 259: $upload_state['index'] = $_POST['index'] + 1;
Line 262: $result = move_uploaded_file($_FILES['chunk']['tmp_name'], $filename);
Line 272: * Stitch together uploaded chunks into an actual file
Line 279: * @post num The total number of chunks uploaded
Line 280: * @post string code Unique code for this upload
Line 283: public function uploadDone()
Line 285: $upload_state = &$this->session();
Line 292: if ($upload_state['index'] !== $_POST['num']) {
Line 293: Json::error('Invalid number of chunks uploaded');
Line 296: $dest_filename = 'upload-' . time() . '-' . $_POST['code'] . '.dat';
Line 301: if ($total_size !== $upload_state['size']) {
Line 302: Json::error('Final filesize didn\'t match upload size');
Line 315: * Returns the form for updating a file which has been uploaded
Line 322: public function uploadForm()
Line 330: if (!FileUpload::checkFilename($_GET['file']['name'])) {
Line 331: $error = 'This type of file cannot be uploaded';
Line 337: } catch (FileUploadException $ex) {
Line 345: } catch (FileUploadException $ex) {
Line 384: * Stitch together the uploaded file from multiple chunks
Line 387: * @param string $code Upload code
Line 446: * @param string $code The upload session code
Line 460: * Cancel an upload - delete temporary files.
Line 463: * [result][tmp_file] Whole file was uploaded
Line 464: * [partial_upload][code] Only some chunks of the file have been uploaded
Line 468: public function uploadCancel()
Line 471: // Whole file was uploaded
Line 472: $result = preg_match('/^upload-[0-9]+-[a-zA-Z0-9]{32}.dat$/', $_POST['result']['tmp_file']);
Line 479: } elseif (isset($_POST['partial_upload']['code'])) {
Line 480: // Only part of the file has been uploaded
Line 481: $result = preg_match('/^[a-zA-Z0-9]{32}$/', $_POST['partial_upload']['code']);
Line 486: $files = glob(APPPATH . 'temp/chunk-' . $_POST['partial_upload']['code'] . '-*.dat');
/sprout/Controllers/Tinymce4Controller.php Highlighted file source
Line 61: $view->upload_url = "tinymce4/upload?type=" . $type;
Line 66: $view->upload_label = 'Upload an image';
Line 69: $view->upload_label = 'Upload a video';
Line 72: $view->upload_label = 'Upload a file';
Line 75: $view->can_upload = AdminPerms::controllerAccess('file', 'add');
Line 485: * UI for uploading files
Line 487: public function upload()
Line 492: echo '<p>You do not have permission to upload files.</p>';
Line 496: $view = new View('sprout/tinymce4/upload');
Line 518: $outer->page_title = $view->toolbar->upload_label;
/sprout/Controllers/Tinymce4Controller.php Highlighted file source
Line 61: $view->upload_url = "tinymce4/upload?type=" . $type;
Line 66: $view->upload_label = 'Upload an image';
Line 69: $view->upload_label = 'Upload a video';
Line 72: $view->upload_label = 'Upload a file';
Line 75: $view->can_upload = AdminPerms::controllerAccess('file', 'add');
Line 485: * UI for uploading files
Line 487: public function upload()
Line 492: echo '<p>You do not have permission to upload files.</p>';
Line 496: $view = new View('sprout/tinymce4/upload');
Line 518: $outer->page_title = $view->toolbar->upload_label;
/sprout/Helpers/Fb.php Highlighted file source
Line 375: * Generates a file upload field
Line 380: public static function upload($name, array $attrs = [])
Line 383: self::addAttr($attrs, 'class', 'upload');
Line 389: * Generates a file upload field with a progress bar
Line 391: * To easily save the uploaded files in the form action function, see {@see File::replaceSet}
Line 396: * Data regarding each uploaded file will typically be saved in
Line 397: * $_SESSION['file_uploads'][$params['sess_key']][$name].
Line 411: public static function chunkedUpload($name, array $attrs = [], array $params = [])
Line 414: Needs::fileGroup('drag_drop_upload');
Line 422: 'begin_url' => 'file_upload/upload_begin',
Line 423: 'form_url' => 'file_upload/upload_form',
Line 424: 'chunk_url' => 'file_upload/upload_chunk',
Line 425: 'done_url' => 'file_upload/upload_done',
Line 426: 'cancel_url' => 'file_upload/upload_cancel',
Line 446: $out = '<div class="fb-chunked-upload" data-opts="' . Enc::html(json_encode($opts)) . '">';
Line 448: $upload_params = ['class' => 'file-upload__input', 'id' => $attrs['id']];
Line 449: if ($opts['max_files'] > 1) $upload_params['multiple'] = 'multiple';
Line 450: $out .= self::upload($name . '_upload', $upload_params);
Line 452: $out .= '<div class="file-upload__area textbox">';
Line 455: $out .= '<div class="file-upload__helptext">';
Line 457: $out .= '<span class="file-upload__helptext__line2">or click to upload</span></p>';
Line 461: $out .= '<div class="file-upload__uploads">';
Line 463: // Show uploaded file(s) if there's uploaded file data in the session
Line 495: // Temp uploaded files stored in session
Line 520: $out .= '<div class="file-upload__item"';
Line 532: $out .= '</div>'; // .file-upload__uploads
Line 533: $out .= '</div>'; // .file-upload__area
Line 535: $out .= '<div class="file-upload__data">';
Line 540: $out .= '</div>'; // .file-upload__data
Line 542: $out .= '</div>'; // .fb-chunked-upload
Line 1698: * UI for selecting or drag-and-drop uploading one or more files.
/sprout/Helpers/Fb.php Highlighted file source
Line 375: * Generates a file upload field
Line 380: public static function upload($name, array $attrs = [])
Line 383: self::addAttr($attrs, 'class', 'upload');
Line 389: * Generates a file upload field with a progress bar
Line 391: * To easily save the uploaded files in the form action function, see {@see File::replaceSet}
Line 396: * Data regarding each uploaded file will typically be saved in
Line 397: * $_SESSION['file_uploads'][$params['sess_key']][$name].
Line 411: public static function chunkedUpload($name, array $attrs = [], array $params = [])
Line 414: Needs::fileGroup('drag_drop_upload');
Line 422: 'begin_url' => 'file_upload/upload_begin',
Line 423: 'form_url' => 'file_upload/upload_form',
Line 424: 'chunk_url' => 'file_upload/upload_chunk',
Line 425: 'done_url' => 'file_upload/upload_done',
Line 426: 'cancel_url' => 'file_upload/upload_cancel',
Line 446: $out = '<div class="fb-chunked-upload" data-opts="' . Enc::html(json_encode($opts)) . '">';
Line 448: $upload_params = ['class' => 'file-upload__input', 'id' => $attrs['id']];
Line 449: if ($opts['max_files'] > 1) $upload_params['multiple'] = 'multiple';
Line 450: $out .= self::upload($name . '_upload', $upload_params);
Line 452: $out .= '<div class="file-upload__area textbox">';
Line 455: $out .= '<div class="file-upload__helptext">';
Line 457: $out .= '<span class="file-upload__helptext__line2">or click to upload</span></p>';
Line 461: $out .= '<div class="file-upload__uploads">';
Line 463: // Show uploaded file(s) if there's uploaded file data in the session
Line 495: // Temp uploaded files stored in session
Line 520: $out .= '<div class="file-upload__item"';
Line 532: $out .= '</div>'; // .file-upload__uploads
Line 533: $out .= '</div>'; // .file-upload__area
Line 535: $out .= '<div class="file-upload__data">';
Line 540: $out .= '</div>'; // .file-upload__data
Line 542: $out .= '</div>'; // .fb-chunked-upload
Line 1698: * UI for selecting or drag-and-drop uploading one or more files.
/sprout/Helpers/File.php Highlighted file source
Line 468: * Moves an uploaded file into the repository.
Line 475: public static function moveUpload($src, $filename)
Line 477: return self::backend()->moveUpload($src, $filename);
Line 1029: * Do post-processing after a file upload
Line 1036: public static function postUploadProcessing($filename, $file_id, $file_type)
Line 1141: * Replaces a set of files to be stored in a single field; this acts as a backend for {@see Fb::chunkedUpload}
Line 1145: * @param string $session_key Session key used for this file field, used for {@see FileUpload::verify}
Line 1157: $src_file = FileUpload::verify($session_key, $field_name, $i, $exts);
Line 1161: $res = File::moveUpload($src_file, $dest);
/sprout/Helpers/FileUpload.php Highlighted file source
Line 21: use Sprout\Exceptions\FileUploadException;
Line 25: * Used for managing backend processing of fields which have had data submitted via chunked file uploads,
Line 26: * i.e. where chunked upload data has been stitched together by {@see FileUploadController}
Line 28: class FileUpload
Line 37: * // Expects $_SESSION['file_uploads']['user_details']['avatar']['code'] to be set
Line 38: * $result = FileUpload::verify('user_details', 'avatar', 0, ['jpg', 'gif', 'png']);
Line 42: * see $params['sess_key'] of {@see Fb::chunkedUpload}
Line 48: * @return string Path to temporarily uploaded file; this can be used as the first argument to
Line 49: * {@see File::moveUpload} to put the file in the desired permanent location.
Line 50: * @throws DomainException If the $_POST upload state is invalid.
Line 51: * @throws FileUploadException If there was an issue the uploader should know about, e.g. the file extension isn't permitted.
Line 66: $res = preg_match('/^upload-[0-9]+-([A-Za-z0-9]{32}).dat$/', $temp, $matches);
Line 70: $upload_code = $matches[1];
Line 78: // Check to see that the user is actually the one who uploaded the file
Line 79: if (!isset($_SESSION['file_uploads'][$sess_key][$field][$upload_code])) {
Line 80: throw new FileUploadException('Upload session lost');
Line 85: throw new FileUploadException("This type of file cannot be uploaded for security reasons");
Line 90: throw new FileUploadException("Invalid file extension");
Line 94: throw new FileUploadException("File content doesn't match extension");
Line 102: * Check a given filename is allowed to be uploaded - blocks PHP files etc
Line 124: * Generates a fake upload, including a session entry and a temp symlink, from an existing file on disk.
Line 126: * This allows reuse of existing uploaded files on Form::chunkedUpload fields which support multiple files
Line 129: * @param string $session_key The session key used for file uploads, e.g. 'user-register'
Line 130: * (see {@see Fb::chunkedUpload})
Line 131: * @param string $field_name The name of the field supplied to {@see Fb::chunkedUpload}, e.g. 'photos'
Line 133: * uploaded via the chunked uploader
Line 146: $temp_file = 'upload-' . time() . '-' . $code . '.dat';
Line 151: $_SESSION['file_uploads'][$session_key][$field_name][$code] = ['size' => filesize($real_file)];
/sprout/Helpers/FileUpload.php Highlighted file source
Line 21: use Sprout\Exceptions\FileUploadException;
Line 25: * Used for managing backend processing of fields which have had data submitted via chunked file uploads,
Line 26: * i.e. where chunked upload data has been stitched together by {@see FileUploadController}
Line 28: class FileUpload
Line 37: * // Expects $_SESSION['file_uploads']['user_details']['avatar']['code'] to be set
Line 38: * $result = FileUpload::verify('user_details', 'avatar', 0, ['jpg', 'gif', 'png']);
Line 42: * see $params['sess_key'] of {@see Fb::chunkedUpload}
Line 48: * @return string Path to temporarily uploaded file; this can be used as the first argument to
Line 49: * {@see File::moveUpload} to put the file in the desired permanent location.
Line 50: * @throws DomainException If the $_POST upload state is invalid.
Line 51: * @throws FileUploadException If there was an issue the uploader should know about, e.g. the file extension isn't permitted.
Line 66: $res = preg_match('/^upload-[0-9]+-([A-Za-z0-9]{32}).dat$/', $temp, $matches);
Line 70: $upload_code = $matches[1];
Line 78: // Check to see that the user is actually the one who uploaded the file
Line 79: if (!isset($_SESSION['file_uploads'][$sess_key][$field][$upload_code])) {
Line 80: throw new FileUploadException('Upload session lost');
Line 85: throw new FileUploadException("This type of file cannot be uploaded for security reasons");
Line 90: throw new FileUploadException("Invalid file extension");
Line 94: throw new FileUploadException("File content doesn't match extension");
Line 102: * Check a given filename is allowed to be uploaded - blocks PHP files etc
Line 124: * Generates a fake upload, including a session entry and a temp symlink, from an existing file on disk.
Line 126: * This allows reuse of existing uploaded files on Form::chunkedUpload fields which support multiple files
Line 129: * @param string $session_key The session key used for file uploads, e.g. 'user-register'
Line 130: * (see {@see Fb::chunkedUpload})
Line 131: * @param string $field_name The name of the field supplied to {@see Fb::chunkedUpload}, e.g. 'photos'
Line 133: * uploaded via the chunked uploader
Line 146: $temp_file = 'upload-' . time() . '-' . $code . '.dat';
Line 151: $_SESSION['file_uploads'][$session_key][$field_name][$code] = ['size' => filesize($real_file)];
/sprout/Helpers/Upload.php Highlighted file source
Line 23: * Upload helper class for working with the global $_FILES array and Validation library.
Line 26: class Upload
Line 30: * Save an uploaded file to a new location.
Line 32: * @param mixed name of $_FILE input or array of upload data
Line 49: if (Kohana::config('upload.remove_spaces') === TRUE)
Line 57: // Use the pre-configured upload directory
Line 58: $directory = Kohana::config('upload.directory', TRUE);
Line 64: if ( ! is_dir($directory) AND Kohana::config('upload.create_directories') === TRUE)
Line 66: // Create the upload directory
Line 71: throw new Kohana_Exception('upload.not_writable', $directory);
Line 74: if (is_uploaded_file($file['tmp_name']) AND move_uploaded_file($file['tmp_name'], $path))
Line 92: * Tests if input data is valid file type, even if no upload is present.
Line 108: * Tests if input data has valid upload data.
Line 117: AND is_uploaded_file($file['tmp_name'])
Line 118: AND (int) $file['error'] === UPLOAD_ERR_OK);
Line 122: * Validation rule to test if an uploaded file is allowed by extension.
Line 130: if ((int) $file['error'] !== UPLOAD_ERR_OK)
Line 144: * Validation rule to test if an uploaded file is allowed by file size.
Line 155: if ((int) $file['error'] !== UPLOAD_ERR_OK)
Line 177: } // End upload
/sprout/views/admin/file_add.php Highlighted file source
Line 23: if (!Sprout::browserDragdropUploads() and empty($_GET['force'])) {
Line 24: echo '<p>Your browser doesn\'t support drag-and-drop file uploads.</p>';
Line 34: echo '<p><a href="admin/add/file?force=1">Ignore this warning and let me upload anyway</a></p>';
Line 41: Needs::fileGroup('drag_drop_upload');
Line 46: It's a on-page important style because most other calls to drag_drop_upload.js do want the message hidden -->
Line 48: .file-upload__helptext--hidden { display: block !important; }
Line 63: <div class="field-element field-element--chunkedupload field-element--chunkedupload--form">
Line 64: <div class="field-label"><label for="field5">Upload files</label></div>
Line 66: <div class="fb-chunked-upload" data-opts="<?= Enc::html(json_encode($opts)); ?>">
Line 67: <input class="file-upload__input upload" id="field5" type="file" name="uploader_upload" value="" multiple>
Line 68: <div class="file-upload__area textbox">
Line 69: <div class="file-upload__helptext">
Line 70: <p>Drop file here <span class="file-upload__helptext__line2">or click to upload</span></p>
Line 72: <div class="file-upload__uploads">
/sprout/views/admin/file_add.php Highlighted file source
Line 23: if (!Sprout::browserDragdropUploads() and empty($_GET['force'])) {
Line 24: echo '<p>Your browser doesn\'t support drag-and-drop file uploads.</p>';
Line 34: echo '<p><a href="admin/add/file?force=1">Ignore this warning and let me upload anyway</a></p>';
Line 41: Needs::fileGroup('drag_drop_upload');
Line 46: It's a on-page important style because most other calls to drag_drop_upload.js do want the message hidden -->
Line 48: .file-upload__helptext--hidden { display: block !important; }
Line 63: <div class="field-element field-element--chunkedupload field-element--chunkedupload--form">
Line 64: <div class="field-label"><label for="field5">Upload files</label></div>
Line 66: <div class="fb-chunked-upload" data-opts="<?= Enc::html(json_encode($opts)); ?>">
Line 67: <input class="file-upload__input upload" id="field5" type="file" name="uploader_upload" value="" multiple>
Line 68: <div class="file-upload__area textbox">
Line 69: <div class="file-upload__helptext">
Line 70: <p>Drop file here <span class="file-upload__helptext__line2">or click to upload</span></p>
Line 72: <div class="file-upload__uploads">
/sprout/views/admin/file_selector_popup.php Highlighted file source
Line 21: Needs::fileGroup('drag_drop_upload');
Line 32: <?php if ($browse and $upload): ?>
Line 35: <li><a href="#tab-upload-file">Upload</a></li>
Line 80: <div class="tab" id="tab-upload-file">
Line 82: <?php if ($upload): ?>
Line 85: <!-- Upload -->
Line 86: <form action="SITE/admin/call/file/quickUpload" method="post" target="quick-upload" id="file-selector-upload" data-type="<?php echo $f_type; ?>">
Line 89: <h3 class="popup-subtitle">Upload</h3>
Line 92: echo Form::chunkedUpload('file', [], ['sess_key' => 'admin_quick_upload']);
Line 116: <button type="submit" class="button icon-after icon-file_upload button-green button-regular">Upload</button>
Line 122: <iframe name="quick-upload" id="quick-upload" style="display: none;"></iframe>
/sprout/views/admin/file_selector_popup.php Highlighted file source
Line 21: Needs::fileGroup('drag_drop_upload');
Line 32: <?php if ($browse and $upload): ?>
Line 35: <li><a href="#tab-upload-file">Upload</a></li>
Line 80: <div class="tab" id="tab-upload-file">
Line 82: <?php if ($upload): ?>
Line 85: <!-- Upload -->
Line 86: <form action="SITE/admin/call/file/quickUpload" method="post" target="quick-upload" id="file-selector-upload" data-type="<?php echo $f_type; ?>">
Line 89: <h3 class="popup-subtitle">Upload</h3>
Line 92: echo Form::chunkedUpload('file', [], ['sess_key' => 'admin_quick_upload']);
Line 116: <button type="submit" class="button icon-after icon-file_upload button-green button-regular">Upload</button>
Line 122: <iframe name="quick-upload" id="quick-upload" style="display: none;"></iframe>
/sprout/views/admin/page_import_upload.php Highlighted file source
Line 18: <form action="admin/call/page/importUploadAction" method="post" enctype="multipart/form-data" class="-clearfix">
Line 28: <input type="file" class="upload" name="import" id="fb1">
Line 48: <h2 class="icon-before icon-file_upload">Import</h2>
Line 51: <button type="submit" class="save-changes-save-button button button-regular button-green icon-after icon-send">Upload file</button>
/sprout/views/admin/page_import_upload.php Highlighted file source
Line 18: <form action="admin/call/page/importUploadAction" method="post" enctype="multipart/form-data" class="-clearfix">
Line 28: <input type="file" class="upload" name="import" id="fb1">
Line 48: <h2 class="icon-before icon-file_upload">Import</h2>
Line 51: <button type="submit" class="save-changes-save-button button button-regular button-green icon-after icon-send">Upload file</button>
/sprout/views/dbtools/module_builder_existing_upload.php Highlighted file source
Line 31: <form action="SITE/dbtools/moduleBuilderExistingUploadAction" method="post" enctype="multipart/form-data" class="white-box">
Line 33: Form::nextFieldDetails('Upload db_struct.xml', true);
Line 34: echo Form::upload('file');
Line 37: <button type="submit" class="button icon-after icon-file_upload">Upload and process XML</button>
Line 41: <form action="SITE/dbtools/moduleBuilderExistingUploadAction" method="post" class="white-box">
Line 47: <button type="submit" class="button icon-after icon-file_upload">Process XML</button>
Line 51: <form action="SITE/dbtools/moduleBuilderExistingUploadAction" method="post" class="white-box">
Line 57: <button type="submit" class="button icon-after icon-file_upload">Process XML</button>
/sprout/views/dbtools/module_builder_existing_upload.php Highlighted file source
Line 31: <form action="SITE/dbtools/moduleBuilderExistingUploadAction" method="post" enctype="multipart/form-data" class="white-box">
Line 33: Form::nextFieldDetails('Upload db_struct.xml', true);
Line 34: echo Form::upload('file');
Line 37: <button type="submit" class="button icon-after icon-file_upload">Upload and process XML</button>
Line 41: <form action="SITE/dbtools/moduleBuilderExistingUploadAction" method="post" class="white-box">
Line 47: <button type="submit" class="button icon-after icon-file_upload">Process XML</button>
Line 51: <form action="SITE/dbtools/moduleBuilderExistingUploadAction" method="post" class="white-box">
Line 57: <button type="submit" class="button icon-after icon-file_upload">Process XML</button>
/sprout/views/tinymce4/upload.php Highlighted file source
Line 27: Upload files using the form below.
Line 31: <form action="SITE/admin/call/file/quickUpload" method="post" target="quick-upload" enctype="multipart/form-data" id="mce-upload">
Line 35: <?= Form::chunkedUpload('file', [], ['sess_key' => 'admin_quick_upload']); ?>
Line 45: <input class="button" type="submit" value="Upload">
Line 50: <iframe name="quick-upload" id="quick-upload" style="display: none;"></iframe>
Line 56: $('#quick-upload').on("load", function() {
Line 57: var nfo = $('#quick-upload').contents().find('div').text();
Line 68: alert('Your file has been uploaded successfully, but is the wrong type for this field.');
Line 80: $('#mce-upload .emu-mce-upload').change(function() {
Line 93: $('#mce-upload select[name="category_id"]').change(function() {
Line 96: $('#mce-upload input[name="category_new"]').select();
/sprout/views/tinymce4/upload.php Highlighted file source
Line 27: Upload files using the form below.
Line 31: <form action="SITE/admin/call/file/quickUpload" method="post" target="quick-upload" enctype="multipart/form-data" id="mce-upload">
Line 35: <?= Form::chunkedUpload('file', [], ['sess_key' => 'admin_quick_upload']); ?>
Line 45: <input class="button" type="submit" value="Upload">
Line 50: <iframe name="quick-upload" id="quick-upload" style="display: none;"></iframe>
Line 56: $('#quick-upload').on("load", function() {
Line 57: var nfo = $('#quick-upload').contents().find('div').text();
Line 68: alert('Your file has been uploaded successfully, but is the wrong type for this field.');
Line 80: $('#mce-upload .emu-mce-upload').change(function() {
Line 93: $('#mce-upload select[name="category_id"]').change(function() {
Line 96: $('#mce-upload input[name="category_new"]').select();
A total of 660 lines in 46 files were found