استعمل مربع البحث في الاسفل لمزيد من المواضيع
سريع للبحث عن مواضيع في المنتدى
-
11-01-2013, بتوقيت غرينيتش 10:02 AM
#1
[كلاس] upload للرفع
[ظƒظ„ط§ط³] upload ظ„ظ„ط±ظپط¹
بسم الله الرحمن الرحيم
ايه اخباركم ؟؟
انا لسه مخلص كلاس الupload و الكلاس ده جزء من الframework قررت تطرح هنا مجانا و ان شاء الله راح تكون اول framework عربي و يا ريت لو في حد بيعرف يحلل
انا محتاج مساعدة في التحليل
و بس الكلاس اهه
رمز PHP:
<code style="white-space:nowrap"> <code>
<?php
/*
* @author: Ahmed H AboElnasser <[email protected]>
* @license MIT
* @since: Class available since EgySolutions Framework 0.1 Beta
* @link: http://www.egysolutions.net
* Requires: PHP 5.1.4+
* @package: EgySolutions Framework
* @category: core
* @subpackage upload
*/
class upload
{
private $file = array();
private $upload_folder = '';
private $max_filesize = 0; // in bytes!
private $valid_extensions = array();
private $extension = '';
private $new_filename = '';
public $filename = '';
public $done = false;
/**
* Create an upload stream, check filesize and extension as well as correct upload form
*
* @global $cfg
*/
function __construct( $file = array(), $upload_folder = '', $new_filename = '', $valid_extensions = array(), $max_filesize = 0 )
{
global $cfg;
// Set class vars
$this->file = $file;
$this->filename = $this->file['name'];
$this->valid_extensions = $valid_extensions;
$this->new_filename = $new_filename;
$this->upload_folder = $upload_folder;
// check if the array is filled
if( !isset( $this->file['name'] ) OR !isset( $this->file['tmp_name'] ) OR !isset( $this->file['size'] ) )
return false;
// max filesize in bytes
$this->max_filesize = ( $max_filesize != 0 ) ? $max_filesize : $cfg->max_upload_filesize;
if( $this->_check_extension() AND $this->_check_filesize() )
{
$this->filename = $this->new_filename . '.' . $this->extension;
$this->done = move_uploaded_file($this->file['tmp_name'], $this->upload_folder . $this->filename );
}
else
{
return false;
}
}
/**
* Check if the exitension is valid
*/
private function _check_extension()
{
$info = explode('.',$this->filename);;
$ext = $info[(count($info))-1];
if( in_array( $ext, $this->valid_extensions ) )
{
$this->extension = strtolower($ext);
return true;
}
else
return false;
}
/**
* Check if the filesize is valid
*/
private function _check_filesize()
{
if( $this->file['size'] < $this->max_filesize )
return true;
else
return false;
}
}
?> </code> </code>

©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى©
المواضيع المتشابهه
-
بواسطة Chakira في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 04:00 PM
-
بواسطة said في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 02:48 PM
-
بواسطة walid في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 01:08 PM
-
بواسطة admin في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 10:02 AM
-
بواسطة admin في المنتدى لغات البرمجه للويب
مشاركات: 0
آخر مشاركة: 11-01-2013, بتوقيت غرينيتش 09:55 AM
ضوابط المشاركة
- لا تستطيع إضافة مواضيع جديدة
- لا تستطيع الرد على المواضيع
- لا تستطيع إرفاق ملفات
- لا تستطيع تعديل مشاركاتك
-
قوانين المنتدى