]> git.andy128k.dev Git - ipf.git/commitdiff
Check image format for upload image file
authoravl <alex.litovchenko@gmail.com>
Thu, 11 Sep 2008 00:51:50 +0000 (03:51 +0300)
committeravl <alex.litovchenko@gmail.com>
Thu, 11 Sep 2008 00:51:50 +0000 (03:51 +0300)
ipf/form/field/file.php
ipf/form/field/image.php

index 646c6eb08a0e6bad0907ba8f22179c66b0f6af91..a6205ac4423af25a234c7a073a268c56a0f458a7 100644 (file)
@@ -69,24 +69,12 @@ function IPF_Form_Field_moveToUploadFolder($value, $params=array())
     if (!move_uploaded_file($value['tmp_name'], $dest)) {
         throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.'));
     } 
-    @chmod($dest, 0666);
+    @chmod($dest, IPF::get('file_permission'));
     return $name;
 }
 
 
 function IPF_Form_Field_removeFile($value, $params=array())
 {
-    /*
-    $name = IPF_Utils::cleanFileName($value['name']);
-    $upload_path = IPF::get('upload_path', '/tmp');
-    if (isset($params['upload_path'])) {
-        $upload_path = $params['upload_path'];
-    }
-    $dest = $upload_path.DIRECTORY_SEPARATOR.$name;
-    if (!move_uploaded_file($value['tmp_name'], $dest)) {
-        throw new IPF_Exception_Form(__('An error occured when upload the file. Please try to send the file again.'));
-    } 
-    @chmod($dest, 0666);
-    */
     return null;
 }
index 0a35c707444f8ba32f639f049ba104ea90d5a6ef..8591f4b37eeea5220bfd81bca47fd801c875a601 100644 (file)
@@ -2,4 +2,21 @@
 
 class IPF_Form_Field_Image extends IPF_Form_Field_File{
     public $widget = 'IPF_Form_Widget_Image';
+    public $move_function = 'IPF_Form_Field_moveImageToUploadFolder';
 }
+
+function IPF_Form_Field_moveImageToUploadFolder($value, $params=array())
+{
+    $name = IPF_Form_Field_moveToUploadFolder($value, $params);
+    $upload_path = IPF::get('upload_path', '/tmp');
+    if (isset($params['upload_path'])) {
+        $upload_path = $params['upload_path'];
+    }
+    $image = $upload_path.DIRECTORY_SEPARATOR.$name;
+
+    if(!getimagesize($image))
+        throw new IPF_Exception_Form(__('An error occured when upload the image.'));
+
+    return $name;
+}
+