diff --git a/Simple-Ajax-Uploader-master.zip b/Simple-Ajax-Uploader-master.zip new file mode 100644 index 0000000..835085a Binary files /dev/null and b/Simple-Ajax-Uploader-master.zip differ diff --git a/index.php b/index.php index 052bf9e..fd098bd 100755 --- a/index.php +++ b/index.php @@ -64,8 +64,8 @@ $cantidad_registros ="10"; /// j=ADDON EMBEBIDO * /// a= Aplicacion /// p= Aplicacion -$destacados = mas_visto("ultimos","6","6"); -$aleatorios = mas_visto("aleatorios","6","6"); +//$destacados = mas_visto("ultimos","6","6"); +//$aleatorios = mas_visto("aleatorios","6","6"); //if (isset($_GET['v'])) {$variable = $_GET['v'];}else {$variable = "";} if (isset($_REQUEST['empresa'])) {$variable = "e".$_REQUEST['empresa'];} elseif (isset($_REQUEST['form']) AND isset($_REQUEST['embebido']) ) {$variable = "g".$_REQUEST['form'];} diff --git a/upload/Simple-Ajax-Uploader-master/Changelog.md b/upload/Simple-Ajax-Uploader-master/Changelog.md new file mode 100755 index 0000000..4ea76fd --- /dev/null +++ b/upload/Simple-Ajax-Uploader-master/Changelog.md @@ -0,0 +1,342 @@ +Change Log +============================ +### Version 2.6.2 ### +* Added UTF-8 encoding to `X-File-Name` request header + +### Version 2.6.1 ### +SimpleAjaxUploader.js: +* Added disabled status check to file button keyboard support +* Fixed bug in `_getProg` method where undefined error was occurring after `destroy()` method has been called + +### Version 2.6 ### +SimpleAjaxUploader.js: +* Added keyboard support for file button. Pressing Enter while focused on file select button now opens file dialog box - #183 (Special thanks to phy25 for this.) +* Added new `multipleSelect` option to allow/disallow multiple file selection (default `false`) +* Modified `multiple` option to now only control whether multiple, concurrent uploads are permitted +* Added new `onDone( filename, status, statusText, response, uploadBtn, size )` method which fires after each individual upload finishes +* Added new `onAllDone()` method which fires when all active uploads finish +* Added JSHint comments to suppress "better written in dot notation" warnings + +Uploader.php: +* Added `getFileNameWithoutExt` method - #182 (Special thanks to sainrew for this) + +### Version 2.5.5 ### +SimpleAjaxUploader.js: +* Improved drag detection to work around Firefox bug which causes `dragenter` to fire twice (https://bugzilla.mozilla.org/show_bug.cgi?id=804036) +* Set `dataTransfer.dropEffect` to `copy` during `dragover` event + +Uploader.php: +* Improved filename sanitation +* Replaced instances of `array_key_exists` with the faster `isset` + +### Version 2.5.4 ### +SimpleAjaxUploader.js: +* Added check for parent node inside of `ss.isVisible()` - #160 + +### Version 2.5.3 ### +SimpleAjaxUploader.js: +* Fixed issue with `dragleave` firing when hovering a child element - #156 - (Special thanks to JulesDoe for this) + +### Version 2.5.2 ### +SimpleAjaxUploader.js: +* Added param check before appending file to allow for manually appended files - #155 (Special thanks to ablipan for this) +* Fixed check of the internal variable which tracks active upload count to check as integer rather than `length` property - #150 (Special thanks to benzamin for this) + +Examples: +* Cleaned up buggy code in README examples - #150 (Special thanks to benzamin for this) + +### Version 2.5.1 ### +SimpleAjaxUploader.js: +* When returning `false` from `onSubmit()`, files will now be removed from queue automatically + +### Version 2.5.0 ### +SimpleAjaxUploader.js: +* Removed additional name parameter from XHR uploads - #141 (Special thanks to djxhero for this one) + +### Version 2.4 ### +SimpleAjaxUploader.js: +* `multipart` option now defaults to `true` +* `noParams` option now defaults to `true` + +Note: One or both of the above changes may be potentially breaking for anyone not using the included Uploader.php class. If this is the case, the fix is to explicitly set both of these options to `false` in your plugin settings. More info: #137 + +* Added form integration functionality -- new option `form` and new method `setForm()`. See README.md for details +* Added `addButton()` method for adding upload buttons - #104 +* Added `addDZ()` method for designating an element as a drop zone +* Added `customProgressHeaders` option to include additional, custom request headers to upload progress update requests in legacy browsers +* Added `autoCalibrate` option (default `true`). When `autoCalibrate` is `true`, upload buttons which are not visible at initialization will be auto reset with `updatePosition()` upon becoming visible +* Added `onBlankSubmit()` callback function to be called when user attempts to submit without selecting a file - #101 +* Improved event handler management for iFrame uploads +* Reconfigured code structure into more logical format + +### Version 2.3 ### +SimpleAjaxUploader.js: +* Added UTF-8 encoding to XHR request headers in order to handle all characters/languages - #126, #128 +* Added `encodeHeaders` option to enable/disable UTF-8 encoding of XHR request headers (default is `true`) +* Removed `encodeCustomHeaders` option, as it is no longer necessary with newly added UTF-8 encoding for all headers +* `onChange()` callback function now receives the selected file as its 5th argument - #132 +* Added `withCredentials` option to include user credentials in upload request (default is `false`) +* Updated `ss.trim()` to use native String.trim if available +* Drag and drop file selection now correctly honors `return false` from `onChange()` callback function +* Updated drag and drop functionality to cancel default action for `ondragover` and `ondragenter` per https://msdn.microsoft.com/library/ms536929(v=vs.85).aspx + +### Version 2.2.4 ### +SimpleAjaxUploader.js: +* Added pre-check for element and class name params to `ss.hasClass`, `ss.addClass`, and `ss.removeClass` methods + +Uploader.php: +* Added `getMimeType($filename)` method for detecting the MIME Content-type of a file using the PHP finfo class +* Added `isWebImage($filename)` method for checking whether a file is either a GIF, PNG, or JPEG using exif_imagetype + +More info about the new methods can be found at: https://www.lpology.com/code/ajaxuploader/phpdocs.php + +### Version 2.2.3 ### +SimpleAjaxUploader.js: +* Fixed bug in `destroy()` method that was throwing error in property delete loop + +### Version 2.2.2 ### +* Switched to an improved UMD implementation +* `X-File-Name` request header is now encoded when `encodeCustomHeaders` is set to `true` +* Added a few small mem leak fixes for IE9 and older + +### Version 2.2.1 ### +SimpleAjaxUploader.js: +* Added file size as argument passed to `onComplete( filename, response, uploadBtn, size )` callback function +* Added file size as argument passed to `onError( filename, type, status, statusText, response, uploadBtn, size )` callback function +* Added file size as argument passed to `onAbort( filename, uploadBtn, size )` callback function + +Package Management: +* Added package.json +* Added bower.json +* Added CommonJS support + +Documentation: +* Updated API reference to fix missing and incomplete SimpleAjaxUploader.js API coverage + +### Version 2.2 ### +SimpleAjaxUploader.js: +* Upload buttons are now clickable for 100% of height +* Changed mouseover and mouseout events from input field to div wrapper for better responsiveness +* Fixed bug where file input layout visibility was not returning to invisible on mouseout if `hoverClass` option not defined + +Uploader.php: +* Added check to verify that upload directory exists before checking writability in order to provide more precise error messages + +Documentation: +* Added FAQ: https://www.lpology.com/code/ajaxuploader/faq.php + +### Version 2.1.1 ### +SimpleAjaxUploader.js: +* Fixed `onChange()` button argument bug - #115 (Special thanks to zaygraveyard for this.) + +### Version 2.1 ### +SimpleAjaxUploader.js: +* Headers are no longer URL encoded by default. A new option `encodeCustomHeaders` has been added, which when set to `true` will result in custom headers being URL encoded. +* Added `updatePosition()` method for correcting the position of the upload button after interacting with form - #105 - (Special thanks to vovayatsyuk for this.) +* Fixed drop zone element z-index bug +* Moved verification of drop zone element to inside of constructor + +### Version 2.0.1 ### +Uploader.php: +* Fixed file name security vulnerability - #91 - (Special thanks to nickgardos for this) + +SimpleAjaxUploader.js: +* Added support for Cyrillic characters in file names - #88 - (Special thanks to a-dorosh for this) +* Fixed issue with drag class not being removed on drag error + +### Version 2.0 ### + +SimpleAjaxUploader.js: + +* Added support for drag and drop file uploads +* Added `ss.uploadSetup()` method to set default uploader option values (useful for multiple uploader instances) +* Added `noParams` option to disable the default behavior of appending the file name to the URL query string +* Numerous code improvements throughout -- bug fixes, memory usage, etc. + +Uploader.php: +* Refactored into a single class in accordance with one class, one file +* Made improvements to error detection and handling +* Added support for reading the `X-File-Name` header as an alternative to query string parameters for sending file names to the server +* Set default value of the `$uploadName` property to be `"uploadfile"` for consistency with the examples - #72 + +### Version 1.11 ### +* Added support for PHP Session Upload Progress for PHP 5.4+ (APC was deprecated in 5.3) +* Added `clearQueue()` method which gives the user the ability to clear all files in queue - #62 - (Special thanks to mouse0270 for this one) +* Fixed multiple file selection bug - #67 - (Special thanks to genintho for this) +* Fixed bug which could allow form/input elements to be created with invalid name/ID attributes in IE7-9 + +### Version 1.10.1 ### +* `iframe` and `form` elements are now created with `document.createElement()` rather than the much slower HTML injection method +* Removed unused variable from `_uploadIframe()` + +### Version 1.10 ### +* Added `setOptions()` method for setting or changing upload options - #54 - (special thanks to hauru for this) +* Added `customHeader` option for sending custom request headers - #47 (special thanks to cillosis for this) +* Updated `ss.parseJSON()` to use a more secure method of manually parsing JSON + +### Version 1.9.1 ### +* `onError()` callback now receives server response as an argument, if it exists, or `false` if it does not - #37 (special thanks to KSDaemon for this) +
+
+API Change Note: For consistency with the other callbacks, the server response is passed to `onError()` as the next to last argument, directly before the upload button. Therefore, if you use the upload button parameter in `onError()`, you will need to update your code when upgrading. +
+
+* Switched from Google Closure Compiler to YUI Compressor for minification + +### Version 1.9 ### +* Added CORS support - Learn more +* Query string parameters for Nginx Upload Progress Module in `_uploadIframe()` are now encoded with `encodeURIComponent()` +* Upload progress ID keys are now generated prior to each upload instead of on page load +* Query string parameters passed to `url` are now preserved - #34 (special thanks to Deefjuh for this) + +### Version 1.8.2 ### +* A reference to the button which triggers an upload is now passed as the last argument to the following callbacks: `onAbort()`, `onChange()`, `onSubmit()`, `onComplete()`, `onError()`, `startXHR()`, `endXHR()`, `startNonXHR()`, `endNonXHR()` (can be useful when using multiple upload buttons) +* Fixed bug which caused some methods to not work if called inside of `startXHR()` or `startNonXHR()` +* Fixed bug causing undefined variable in IE9 and older if `progressUrl` and `nginxProgressUrl` are not set + +### Version 1.8.1 ### +* Added `destroy()` method for completely removing upload functionality +* Removed redundant call to `ss.verifyElem()` inside of `rerouteClicks()` +* Moved browser-specific checks to top of IIFE, as they only need to execute once + +### Version 1.8 ### +SimpleAjaxUploader.js: +* Added support for Nginx Upload Progress Module +* Added `setAbortBtn()` method to designate an element as "cancel" button +* Added `onAbort()` callback function to specify behavior upon manual abort +* Added `setPctBox()` method to designate an element to be injected with upload progress percentage +* Switched to a unique ID function that is RFC 4122 version 4 compliant +* The `button` option now accepts either a single button (element ID string, element, or jQuery object), or an array of buttons. If an array is passed, each element in the array will work as an upload button +* Upload progress update request keys are now locally generated +* Fixed bug that was causing `onError()` to be fired twice +* For consistency with jQuery behavior, any 2xx status code is now handled as a successful response (previously, only `200` and `201` were successful) +* Upload buttons are now being properly disabled/enabled at correct points +* Made significant improvements to error handling, particularly with iframe uploads and retrieving server provided progress updates +* Fixed a number of potential memory leaks for Internet Explorer +* Regular expressions are now pre-compiled and cached for better performance +* For server progress tracking, `sizeBox` and `onUpdateFileSize()` are no longer pointlessly set/called again after first progress update is received + +uploadProgress.php: +* Removed functionality for returning upload keys, as RFC 4122 v4 compliant UUIDs are now generated client side + +### Version 1.7 ### +SimpleAjaxUploader.js: +* Fixed IE6/IE7 memory leak when removing elements without first removing event listeners (issue #21) +* Fixed possible race condition in which `removeCurrent()` could potentially delete the wrong file from the upload queue +* Multiple file inputs are now disabled in Safari due to a browser bug that just screws everything up (see: http://stackoverflow.com/q/7231054/1091949) +* Switched to a smaller, faster process for cross-browser bounding box calculation +* Updated to faster methods of checking for, adding, and removing element CSS classes +* Combined `_checkExtension()` with `_checkFile()` to eliminate a function call/reduce code size +* Combined `_handleIframeResponse()` with `_uploadIframe()` and switched to a more efficient method of getting iframe contents +* Removed a number of unnecessary/redundant function calls, along with some unnecessary variable copying +* Updated `ss.verifyElem()` to use the much faster `charAt()` and `substr()` in place of a regex and `slice()` +* Added separate feature detection for file input `accept` attribute + +Uploader.php: +* Removed unnecessary check of `$allowedExtensions` for `null` value in `handleUpload()` +* Added `final` keyword to `FileUploadXHR` and `FileUploadPOSTForm` classes and their respective methods to discourage direct use + +### Version 1.6.5 ### +* When using `multipart`, additional data will now also appended to the multipart form. +* Cleaned up some messy code -- organization, unnecessary variable copying, etc. + +### Version 1.6.4 ### +* Switched from using `setAttribute` to dot notation for setting element properties (some versions of IE don't handle `setAttribute` well) +* `ss.removeItem()` now uses the faster countdown method to loop through arrays +* In accordance with W3 standards, `_uploadXhr()` now accepts either a `200 OK` or `201 Created` as a successful response +* Uploader.php -- the `handleUpload()` method now checks whether the `allowedExtensions` property is `empty` instead of `null`. This prevents an "Invalid file type" error resulting from passing an empty array + +### Version 1.6.3 ### +* Fixed bug which allowed `onComplete()` to be called after JSON parse error + +### Version 1.6.2 ### +* Overhauled error handling to fix a number of issues. +* Added consistent error types for `onError()` so that the second parameter will be either: +`parseerror` (bad JSON from server), `transfererror` (xfer error during XHR upload), `servererror` (server response not `200 OK`) +* Fixed problem with null file size parameter for `endXHR()` callback + +### Version 1.6.1 ### +* Plugin is now wrapped in an IIFE +* Leading semicolon added to close any previous statement +* Code is now in strict mode +* Cleaned up a few messy areas + +### Version 1.6 ### +If the 1.6 release has a theme, it is flexibility. Nearly every update in this release is intended to allow greater flexibility for developers. + +* Submitting a file which exceeds `maxSize` or is not an `allowedExtension` no longer triggers an alert, but will instead fire a callback +* Added `onSizeError()` callback function which fires when a file exceeds the `maxSize` option, if it is set +* Added `onExtError()` callback which fires when a file is not permitted by the `allowedExtensions` option, if it is set +* Removed `messages` option and `_errorMsg()`, both of which are no longer used +* Added new `accept` option, the value of which will be the value of the `accept` file input attribute in supporting browsers. More info. +* Added new `method` option to allow specifying an HTTP method other than POST + +Special thanks to dleffler, devtrends and urcadox for their ideas and feedback. + +### Version 1.5.3 ### +* Added `autoSubmit` check before submitting in `_cycleQueue()` +* Added check to ensure upload progress server key doesn't exceed 57 characters (max allowable APC key length) +* `rerouteClicks(element)` can now be used to add additional elements which can be clicked to open file box + +### Version 1.5.2 ### +(This isn't as much a release as it is a signal to update for anyone who may have downloaded version 1.5.1 in the past few hours) +* Fixed "bug" from 1.5.1 that broke uploader without multiple option enabled +* Added `queue` option to disable automatic file queuing + +### Version 1.5.1 ### +* Multiple file inputs are now used in browsers with support for File API, thus allowing multiple file selection if `multiple` option is `true` +* Removed some unnecessary variable copying +* Added queue system which allows files to be selected and automatically uploaded as others finish +* Added `getQueueSize()` function to get current number of files waiting in queue +* Fixed bug in which active upload counter was not properly updating when returning `false` from `startXHR()` and `startNonXHR()` +* Error messages now incorporate file names + +### Version 1.5 ### +* Added support for multiple file uploading, along with Gmail-style multiple progress bars for tracking each file. +* Added new `maxSize` option for file size limits, `allowedExtensions` option for file type restrictions. Custom error messages supported for both. +* Updated `verifyElem()` to use a better method of detecting if an upload button is a jQuery object. +* Numerous code enhancements throughout - updated error handling, cleaner organization, performance improvements. +* Patched some memory leaks created by circular references in event handlers. + +### Version 1.4.2 ### +* SimpleAjaxUploader.js - Added `multipart` option to allow multipart form upload instead of binary stream +* Uploader.php - The check for form uploads is now first in the constructor to accomodate new `multipart` option +* Uploader.php - Providing an array of valid file extensions is now optional. If not provided, all file types are allowed +* Added minified version of JS file + +### Version 1.4.1 ### +* Fixed XHR status check logic that could allow false alarm calls to onError callback +* Removed redundant XHR status check +* Returning false from a callback no longer clears the file field. Not sure why it ever did to begin with. +* A status check now occurs prior to progress update requests to prevent potential loop that could be caused by a server error +* Parsing JSON in older browsers no longer uses `eval` because it's evil + +### Version 1.4 ### +This release includes a major overhaul that adds functionality for implementing cross-browser upload progress support. Through feature detection and abstraction, it is now possible for the `onProgress` callback function to maintain consistent behavior across browsers. + +Currently, only PHP (with APC extension) is supported. To use, set the newly added `progressUrl` option to the URL of the included UploadProgress.php script, and `onProgress` will then return upload progress data in Internet Explorer 9 and below. + +Note that this added functionality does not affect the behavior of the plugin for those not using PHP, or just not using the feature. + +For those not using PHP, a similar result can still be achieved with the `startXH`/`endXHR` and `startNonXHR`/`endNonXHR` callback functions, which are included specifically for defining behavior based on whether XHR uploads are supported. + +Also, adding support for other programming languages would certainly be a welcome addition, if anyone is interested in working on that. + +Other items: + +* Added `onUpdateFileSize` callback function for getting file size in IE9 and below (When server supported progress is enabled) +* Removed the unneccessary _handleJSON method +* Added new ss.newXHR method +* Added extras folder for non-necessary items (i.e., everything but SimpleAjaxUploader.js) +* Adjusted request headers for XHR uploads +* Moved support detection for HTML5 File API to constructor so it only executes once +* Timestamps now appended to URLs to prevent browsers from caching requests + +### Version 1.3 ### +* Returned to version numbering +* Updated method for parsing JSON +* Added PHP class for handling file uploads +* Cleaned up messy areas + +### Earlier versions ### +Prior to version 1.3, I did a pretty horrible job of documenting changes, and, at one point, entirely dispensed with any notion of version control whatsoever. I have since seen the light. \ No newline at end of file diff --git a/upload/Simple-Ajax-Uploader-master/README.md b/upload/Simple-Ajax-Uploader-master/README.md new file mode 100755 index 0000000..e3673af --- /dev/null +++ b/upload/Simple-Ajax-Uploader-master/README.md @@ -0,0 +1,272 @@ +Simple Ajax Uploader +============================ + +A Javascript plugin for cross-browser Ajax file uploading. Supports drag and drop, CORS, and multiple file uploading with progress bars. Works in IE7-9, mobile, and all modern browsers. + +```javascript +var uploader = new ss.SimpleUpload({ + button: 'upload-btn', // HTML element used as upload button + url: '/PathTo/UploadHandler', // URL of server-side upload handler + name: 'uploadfile' // Parameter name of the uploaded file +}); +``` + +### Features ### +* Cross-browser -- works in IE7+, Firefox, Chrome, Safari, Opera +* Supports multiple, concurrent file uploads (even in non-HTML5 browsers) +* Built-in CORS support +* Drag and drop file uploads (new in v2.0) +* No flash or external CSS -- a single 6Kb Javascript file (minified and gzipped) +* Progress bars in all browsers, including IE9 and older. Built-in support for: + * Nginx Upload Progress Module + * PHP APC File Upload Progress + * PHP Session Upload Progress +* Use any HTML element as the upload button +* No dependencies - use it with or without jQuery +* Provides individual callback functions for XHR-supported browsers and for browsers that do not support XHR uploads +* Ability to pass custom headers in request such as the Authorization header + +### Frequently Asked Questions ### +Visit the new FAQ for solutions to the most common issues. + +### How to Use ### + +Live Demo
+API Reference
+Upload progress bars in IE9 (and older)
+CORS — Cross-domain file uploading with Simple Ajax Uploader + +There are two main ways to use the plugin: + +1. Single file uploading - Only one upload allowed at a time. Progress bar is an element that is re-used for each upload.
+2. Multiple file uploading - Allow multiple, concurrent file uploads. Progress bars are created on the fly before each upload. + +#### Method 1: Single file uploading (one file at a time) #### + +Before each upload, in the `onSubmit()` callback function, the on-page sizeBox and progress elements are assigned specific roles using these two functions: + +`setProgressBar(elem)` - Designates an element as the progress bar for an upload.
+`setFileSizeBox(elem)` - Designates an element as the container in which the file size of an uploading file will be inserted. + +As a result, when an upload begins, the file size of the upload is inserted into the sizeBox element and the CSS width of the progress element is set to 0%. As the upload progresses, the CSS width percentage of the progress element will be updated accordingly. + +This approach of assigning roles to elements provides developers with a great deal of flexibility -- progress indicators can be styled in any way and placed anywhere on the page. + +```javascript +var sizeBox = document.getElementById('sizeBox'), // container for file size info + progress = document.getElementById('progress'); // the element we're using for a progress bar + +var uploader = new ss.SimpleUpload({ + button: 'uploadButton', // file upload button + url: 'uploadHandler.php', // server side handler + name: 'uploadfile', // upload parameter name + progressUrl: 'uploadProgress.php', // enables cross-browser progress support (more info below) + responseType: 'json', + allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], + maxSize: 1024, // kilobytes + hoverClass: 'ui-state-hover', + focusClass: 'ui-state-focus', + disabledClass: 'ui-state-disabled', + onSubmit: function(filename, extension) { + this.setFileSizeBox(sizeBox); // designate this element as file size container + this.setProgressBar(progress); // designate as progress bar + }, + onComplete: function(filename, response) { + if (!response) { + alert(filename + 'upload failed'); + return false; + } + // do something with response... + } +}); +``` + +#### Method 2: Multiple file uploads #### + +Below is an example of how to implement multiple file uploading with progress bars. A new progress bar is created for each file upload within the `onSubmit()` callback function. + +Like in Method 1, the newly created elements are assigned roles using the `setProgressBar()` and `setFileSizeBox()` functions. Unlike the previous example, however, the progress elements are automatically removed when the upload is completed. + +```javascript +var uploader = new ss.SimpleUpload({ + button: 'uploadButton', + url: 'uploadHandler.php', // server side handler + progressUrl: 'uploadProgress.php', // enables cross-browser progress support (more info below) + responseType: 'json', + name: 'uploadfile', + multiple: true, + allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'], // for example, if we were uploading pics + hoverClass: 'ui-state-hover', + focusClass: 'ui-state-focus', + disabledClass: 'ui-state-disabled', + onSubmit: function(filename, extension) { + // Create the elements of our progress bar + var progress = document.createElement('div'), // container for progress bar + bar = document.createElement('div'), // actual progress bar + fileSize = document.createElement('div'), // container for upload file size + wrapper = document.createElement('div'), // container for this progress bar + //declare somewhere:
where you want to show the progress-bar(s) + progressBox = document.getElementById('progressBox'); //on page container for progress bars + + // Assign each element its corresponding class + progress.className = 'progress progress-striped'; + bar.className = 'progress-bar progress-bar-success'; + fileSize.className = 'size'; + wrapper.className = 'wrapper'; + + // Assemble the progress bar and add it to the page + progress.appendChild(bar); + wrapper.innerHTML = '
'+filename+'
'; // filename is passed to onSubmit() + wrapper.appendChild(fileSize); + wrapper.appendChild(progress); + progressBox.appendChild(wrapper); // just an element on the page to hold the progress bars + + // Assign roles to the elements of the progress bar + this.setProgressBar(bar); // will serve as the actual progress bar + this.setFileSizeBox(fileSize); // display file size beside progress bar + this.setProgressContainer(wrapper); // designate the containing div to be removed after upload + }, + + // Do something after finishing the upload + // Note that the progress bar will be automatically removed upon completion because everything + // is encased in the "wrapper", which was designated to be removed with setProgressContainer() + onComplete: function(filename, response) { + if (!response) { + alert(filename + 'upload failed'); + return false; + } + // Stuff to do after finishing an upload... + } +}); +``` + +For multiple file uploads, we use an additional function: `setProgressContainer(elem)`. This function designates an element to be removed from the DOM after the upload is completed. + +In the example, the element set to be removed with `setProgressContainer()` is the outer container for the progress elements. As a result, progress bars will be removed from the DOM after each upload is completed. + +### Form Integration ### + +To integrate the plugin with an existing form so that file uploads include all input fields contained in the form, simply pass the form element to the `form` option, or use the `setForm( form )` instance method. + +Form integration respects any HTML5 validation attributes. Invalid input values will prevent the upload from occurring. + +By default, the plugin will override native submission of the form. Submit attempts will be caught and instead files will be uploaded along with the form data. To disable this behavior, set the `overrideSubmit` to `false`. Setting `overrideSubmit` to `false` will require that the `submit` instance method be manually called in order to upload files and form data together. + +Note: Only use form integration if a file upload is required to be submitted with the form. + +### Cross-Browser Helper Functions ### + +To ease the pain of supporting older browsers, the plugin includes a set of callback functions which allow specific behavior to be defined based on whether the user's browser supports XHR uploads/HTML5 File API: + +startXHR(filename, fileSize) - Called prior to upload -- only in browsers that support XHR uploads
+endXHR(filename) - Called after upload is completed -- only in browsers that support XHR uploads
+startNonXHR(filename) - Called prior to upload -- only in browsers that do not support XHR uploads
+endNonXHR(filename) - Called after upload is completed -- only in browsers that do not support XHR uploads
+ +A common use case is to show an upload progress bar in browsers that support the progress event while displaying an animated GIF in older browsers: + +```javascript + +var progress = document.getElementById('progress'), // progress bar + loaderImg = document.getElementById('loaderImg'); // "loading" animated GIF + +var uploader = new ss.SimpleUpload({ + button: 'uploadButton', + url: 'uploadHandler.php', // server side handler + responseType: 'json', + name: 'uploadfile', + hoverClass: 'ui-state-hover', + focusClass: 'ui-state-focus', + disabledClass: 'ui-state-disabled', + startXHR: function(filename, size) { + progress.style.display = 'inline-block'; // show progress bar + this.setProgressBar(progress); // designate as progress bar + }, + endXHR: function(filename) { + progress.style.display = 'none'; // hide progress bar + }, + startNonXHR: function(filename) { + loaderImg.style.display = 'inline-block'; // show animated GIF + }, + endNonXHR: function(filename) { + loaderImg.style.display = 'none'; // hide animated GIF + } +}); +``` + +Returning false from startXHR() and startNonXHR() will prevent the upload from starting, just as it does with onSubmit() and onChange(). + +### Server-side file handling ### +Files are uploaded by POST as either raw form data or regular multipart/form-data, depending on the browser. + +### Using Uploader.php ### + +Note: This PHP class is included only for convenience. It is not required to use PHP with Simple Ajax Uploader. The plugin is agnostic to server configuration, so use any language you prefer. + +```php +handleUpload($upload_dir, $valid_extensions); + +if (!$result) { + echo json_encode(array('success' => false, 'msg' => $Upload->getErrorMsg())); +} else { + echo json_encode(array('success' => true, 'file' => $Upload->getFileName())); +} +``` + +You can also save the uploaded file with a different name by setting the `newFileName` property: + +```php +$Upload = new FileUpload('uploadfile'); +$ext = $Upload->getExtension(); // Get the extension of the uploaded file +$Upload->newFileName = 'customFileName.'.$ext; +$result = $Upload->handleUpload($upload_dir, $valid_extensions); +``` + +To access the newly uploaded file, use the `getSavedFile()` method to get the file's path after the upload is completed: +```php +$Upload = new FileUpload('uploadfile'); +$result = $Upload->handleUpload($upload_dir, $valid_extensions); + +if ($result) { + $path = $Upload->getSavedFile(); + $imgsize = getimagesize($path); + // image resizing stuff... +} +``` + +### Passing Custom Headers ### + +```javascript +var uploader = new ss.SimpleUpload({ + customHeaders: {'Authorization': 'my-access-token'}, + ... +}); + +``` + +### Drag and Drop ### + +Enable drag and drop uploading by passing an element to the `dropzone` option to serve as the drop zone: + +```javascript +var uploader = new ss.SimpleUpload({ + dropzone: 'dragbox', // ID of element to be the drop zone + url: 'uploadHandler.php', + name: 'uploadfile', + responseType: 'json', + onComplete: function(filename, response) { + // do something with response... + } +}); +``` + + +### License ### +Released under the MIT license. diff --git a/upload/Simple-Ajax-Uploader-master/SimpleAjaxUploader.js b/upload/Simple-Ajax-Uploader-master/SimpleAjaxUploader.js new file mode 100755 index 0000000..0e12bb0 --- /dev/null +++ b/upload/Simple-Ajax-Uploader-master/SimpleAjaxUploader.js @@ -0,0 +1,2277 @@ +/** + * Simple Ajax Uploader + * Version 2.6.2 + * https://github.com/LPology/Simple-Ajax-Uploader + * + * Copyright 2012-2017 LPology, LLC + * Released under the MIT license + */ + +;(function( global, factory ) { + /*globals define, module */ + if ( typeof define === 'function' && define.amd ) { + define( function() { + return factory( global ); + }); + + } else if ( typeof module === 'object' && module.exports ) { + module.exports = factory( global ); + + } else { + global.ss = factory( global ); + } + +}( typeof window !== 'undefined' ? window : this, function( window ) { + +var ss = window.ss || {}, + + // ss.trim() + rLWhitespace = /^\s+/, + rTWhitespace = /\s+$/, + + // ss.getUID + uidReplace = /[xy]/g, + + // ss.getFilename() + rPath = /.*(\/|\\)/, + + // ss.getExt() + rExt = /.*[.]/, + + // ss.hasClass() + rHasClass = /[\t\r\n]/g, + + // Check for Safari -- it doesn't like multi file uploading. At all. + // http://stackoverflow.com/a/9851769/1091949 + isSafari = Object.prototype.toString.call( window.HTMLElement ).indexOf( 'Constructor' ) > 0, + + // Detect IE7-9 + isIE7to9 = ( navigator.userAgent.indexOf('MSIE') !== -1 && + navigator.userAgent.indexOf('MSIE 1') === -1 ), + + isIE7 = ( navigator.userAgent.indexOf('MSIE 7') !== -1 ), + + // Check whether XHR uploads are supported + input = document.createElement( 'input' ), + + XhrOk; + +input.type = 'file'; + +XhrOk = ( 'multiple' in input && + typeof File !== 'undefined' && + typeof ( new XMLHttpRequest() ).upload !== 'undefined' ); + + +/** +* Converts object to query string +*/ +ss.obj2string = function( obj, prefix ) { + "use strict"; + + var str = []; + + for ( var prop in obj ) { + if ( obj.hasOwnProperty( prop ) ) { + var k = prefix ? prefix + '[' + prop + ']' : prop, v = obj[prop]; + str.push( typeof v === 'object' ? + ss.obj2string( v, k ) : + encodeURIComponent( k ) + '=' + encodeURIComponent( v ) ); + } + } + + return str.join( '&' ); +}; + +/** +* Copies all missing properties from second object to first object +*/ +ss.extendObj = function( first, second ) { + "use strict"; + + for ( var prop in second ) { + if ( second.hasOwnProperty( prop ) ) { + first[prop] = second[prop]; + } + } +}; + +ss.addEvent = function( elem, type, fn ) { + "use strict"; + + if ( elem.addEventListener ) { + elem.addEventListener( type, fn, false ); + + } else { + elem.attachEvent( 'on' + type, fn ); + } + return function() { + ss.removeEvent( elem, type, fn ); + }; +}; + +ss.removeEvent = document.removeEventListener ? + function( elem, type, fn ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, fn, false ); + } + } : + function( elem, type, fn ) { + var name = 'on' + type; + + if ( typeof elem[ name ] === 'undefined' ) { + elem[ name ] = null; + } + + elem.detachEvent( name, fn ); + }; + +ss.newXHR = function() { + "use strict"; + + if ( typeof XMLHttpRequest !== 'undefined' ) { + return new window.XMLHttpRequest(); + + } else if ( window.ActiveXObject ) { + try { + return new window.ActiveXObject( 'Microsoft.XMLHTTP' ); + } catch ( err ) { + return false; + } + } +}; + +ss.encodeUTF8 = function( str ) { + "use strict"; + /*jshint nonstandard:true*/ + return unescape( encodeURIComponent( str ) ); +}; + +ss.getIFrame = function() { + "use strict"; + + var id = ss.getUID(), + iframe; + + // IE7 can only create an iframe this way, all others are the other way + if ( isIE7 ) { + iframe = document.createElement('