3600) { // if file is 1 hour (3600 seconds) old then delete it unlink($file); // delete the file } } } } cleanDir(ROOT . '/file-uploads/images/thumbs/lg/*'); cleanDir(ROOT . '/file-uploads/images/thumbs/md/*'); cleanDir(ROOT . '/file-uploads/images/thumbs/sm/*'); cleanDir(ROOT . '/file-uploads/images/*'); cleanDir(ROOT . '/file-uploads/*'); // copy the demo image in file-uploads if it's been deleted by some user if ($_SERVER['SERVER_NAME'] == 'www.phpformbuilder.pro') { if (!file_exists(ROOT . '/file-uploads/images/art-creative-metal-creativity.jpg')) { copy(ROOT . '/assets/images/art-creative-metal-creativity.jpg', ROOT . '/file-uploads/images/art-creative-metal-creativity.jpg'); } } $form = new Form('fileupload-test-form', 'horizontal', 'data-fv-no-icon=true, novalidate'); // $form->setMode('development'); /* ================================================== Single file upload ================================================== */ $fileUpload_config = array( 'upload_dir' => '../../../../../file-uploads/', // the directory to upload the files. relative to phpformbuilder/plugins/fileuploader/default/php/ajax_upload_file.php 'limit' => 1, // max. number of files 'file_max_size' => 2, // each file's maximal size in MB {null, Number} 'extensions' => ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt'], 'debug' => true // log the result in the browser's console and shows an error text on the page if the uploader fails to parse the json result. ); $form->startFieldset('Single file upload'); $form->addHelper('Accepted File Types : .pdf, .doc[x], .xls[x], .txt', 'single-file', 'after'); $form->addFileUpload('file', 'single-file', '', 'Attach a file', '', $fileUpload_config); $form->endFieldset(); /* ================================================== Multiple files upload ================================================== */ $fileUpload_config = array( 'upload_dir' => '../../../../../file-uploads/', // the directory to upload the files. relative to phpformbuilder/plugins/fileuploader/default/php/ajax_upload_file.php 'limit' => 3, // max. number of files 'file_max_size' => 2, // each file's maximal size in MB {null, Number} 'extensions' => ['pdf', 'doc', 'docx', 'xls', 'xlsx', 'txt'], 'debug' => true // log the result in the browser's console and shows an error text on the page if the uploader fails to parse the json result. ); $form->startFieldset('Multiple files upload'); $form->addHelper('3 files maximum. Accepted File Types : .pdf, .doc[x], .xls[x], .txt', 'multiple-files', 'after'); $form->addFileUpload('file', 'multiple-files', '', 'Upload your documents', '', $fileUpload_config); $form->endFieldset(); /* ================================================== Images upload ================================================== */ $fileUpload_config = array( 'xml' => 'image-upload', // the uploader's config in phpformbuilder/plugins-config/fileuploader.xml 'uploader' => 'ajax_upload_file.php', // the uploader file in phpformbuilder/plugins/fileuploader/[xml]/php 'upload_dir' => '../../../../../file-uploads/images/', // the directory to upload the files. relative to [plugins dir]/fileuploader/image-upload/php/ajax_upload_file.php 'limit' => 3, // max. number of files 'file_max_size' => 2, // each file's maximal size in MB {null, Number} 'extensions' => ['jpg', 'jpeg', 'png', 'gif'], // allowed extensions 'thumbnails' => true, // the thumbs directories must exist. thumbs config. is done in phpformbuilder/plugins/fileuploader/image-upload/php/ajax_upload_file.php 'editor' => true, // allows the user to crop/rotate the uploaded image 'width' => 960, // the uploaded image maximum width 'height' => 720, // the uploaded image maximum height 'crop' => false, 'debug' => true // log the result in the browser's console and shows an error text on the page if the uploader fails to parse the json result. ); $form->startFieldset('Multiple images upload with resizing, thumbnails and image editor (crop/rotate)'); $form->addHtml('
The uploader resizes the uploaded image (960px * 720px), then generates large, medium & small thumbnails for each uploaded image.
'); $form->addHelper('3 files max. Accepted File Types : .jp[e]g, .png, .gif