Hello forums
Now i am totally shifting towards OOP..
I had tried to make a upload class but it didnt worked .here is the code
uploader.class.php
<?php
class uploader
{
var $uploadDir;
var $thumbDir;
var $newFileName;
/*var $file_name;
var $file_type;
var $file_size;
var $file_temp_dir;*/
var $fileInfo = array();
var $maxFileSize;
var $allowTypes = array();
var $errMsg = "";
var $suMsg = "";
/***/
var $fileExt;
function getExtension()
{
$fileExt = explode(".",$this->$fileInfo['name']);
$this->fileExt = $fileExt[1];
}
function checkTypes()
{
if(!in_array($this->fileInfo['type'],$this->allowTypes))
{
return FALSE;
}
else
return TRUE;
}
function doUpload()
{
// Check the Size
/* If fileSize > maxSize */
if($this->fileInfo['size'] > $this->maxFileSize)
{
$this->errMsg .= "File Size is larger<br />";
}
/* If fileSize == 0 */
else if($this->fileInfo['size'] == 0)
{
$this->errMsg .= "No file uploaded <br />";
}
/* Check the Types */
else if(!$this->checkTypes())
{
$this->errMsg .= "Invalid file type !! <br />";
}
/* If everything goes fine then Upload */
else
{
//upload to destDir
echo "Final step";
$uploadPath = $this->uploadDir."/".$this->fileInfo['name'];
move_uploaded_file($this->fileInfo['tmp_name'],$uploadPath);
//finally rename
$ext = $this->getExtension();
$newUploadPath = $this->uploadDir."/".$this->newFileName.".".ext;
if(rename($uploadPath,$newUploadPath))
{
$this->suMsg = "Sucessfully Uploaded & Renamed !!";
}
}
}
function deleteFile()
{
}
function renameFile()
{
}
}
?>
action.php
<?php
if(isset($_POST[] ...)
{
include "uploader.class.php";
$uploaderObj = new uploader();
//assign all the variable properties of uploader.class.php
$uploaderObj->doUpload();
}
?>
But nothing happens
What i want ?
1>Any techniques for checking how the class is working ie any debugging tips
2>Any changes in above code to make it efficient and effective Note: its for PHP4 ie any tips n modifications
3> when i try to echo $uploaderObj->getExtension(), it gives the follwing error
Fatal error: Cannot access empty property in C:\Program Files\xampp\htdocs\designtoko\libs\uploader.class.php on line 21
and why it is so
Thanks for reading my post.
Thanks in advance to all of you and awaiting for the results...