Update fileUpload class and the file upload styles.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Apr 2017 18:19:25 +0000 (14:19 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 7 Apr 2017 18:20:24 +0000 (14:20 -0400)
Update the style from the imageUploader on the file.
Update the file upload class so it works with url's also.

js/imageUpload/imageUpload.css
models/admin/ajax/fileUpload.php

index d82fe33..2e15413 100644 (file)
@@ -6,7 +6,7 @@
     text-align: center;
 }
 
-.glm-imageDropContainer
+.glm-imageDropContainer, .glm-fileDropContainer
 {
     position: relative;
     text-align: center;
@@ -21,7 +21,7 @@
     width: 90%;
     height: 2em;
 }
-.glm-imageDrop
+.glm-imageDrop, .glm-fileDrop
 {
     position: absolute;
     width: 100%;
     filter: alpha(opacity=0); /* For IE8 and earlier */
 
 }
-.glm-imageDropText
+.glm-imageDropText, .glm-fileDropText
 {
     color: #666;
     z-index: 9;
 }
-.glm-noImageDropText
+.glm-noImageDropText, .glm-noFileDropText
 {
     color: #666;
 }
-.glm-imageItemHidden
+.glm-imageItemHidden, .glm-fileItemHidden
 {
     display: none;
     z-index: 9;
 }
-.glm-imageDropDragOver
+.glm-imageDropDragOver, .glm-fileDropDragOver
 {
     border: 2px solid #000 important;
     background-color: #fff;
 }
-.glm-imageUploadStatus
+.glm-imageUploadStatus, .glm-fileUploadStatus
 {
     position: absolute;
     width: 100%;
index db226f8..a91553c 100644 (file)
@@ -176,9 +176,14 @@ class GlmMembersAdmin_ajax_fileUpload extends GlmDataImages
 
         // If $file is just a URL to an image, then simulate the file array from a form submission
         if (!is_array($file)) {
+            if ( preg_match( '/^http/', $file ) ) {
+                $fileName = basename( $file );
+            } else {
+                $fileName = $file;
+            }
             $file = array(
                 'tmp_name' => $file,
-                'name' => $file
+                'name'     => $fileName
             );
         }
 
@@ -195,7 +200,12 @@ class GlmMembersAdmin_ajax_fileUpload extends GlmDataImages
             $newFilename = strtolower($fInfo['filename'].'_'.time().'.'.$fInfo['extension']);
         }
 
-        $fileUploaded = move_uploaded_file( $_FILES['file']['tmp_name'], GLM_MEMBERS_PLUGIN_FILES_PATH . '/'. $newFilename );
+        // If the file is in the FILES array
+        if ( isset( $_FILES['file'] ) ) {
+            $fileUploaded = move_uploaded_file( $_FILES['file']['tmp_name'], GLM_MEMBERS_PLUGIN_FILES_PATH . '/'. $newFilename );
+        } else {
+            $fileUploaded = copy( $file['tmp_name'], GLM_MEMBERS_PLUGIN_FILES_PATH . '/'. $newFilename );
+        }
 
         // If we have a good image
         if ( $fileUploaded ) {