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;
}
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;
+}
+