TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 10-01-2008, 12:44 PM   #1 (permalink)
The Wanderer
 
kokjj87's Avatar
 
Join Date: Oct 2008
Posts: 18
Thanks: 0
kokjj87 is on a distinguished road
Help how to capture and show error in oop php to user?

hi, i am new to oop php programming style.. i am trying to write a image class to process images, but how do i capture the error(for example when you upload a non image file) and show it to the user?

PHP Code:
my image class
----------------------------------------------------
<?php
class image
{
private 
$allowextension = array("image/gif","image/jpeg","image/png");
private 
$source;

        function 
__construct($source)
        {
        
$this->source unserialize($source);

                
//check whether the upload file is the extension that is allow
                
if(!in_array(($this->source['type']), $this->allowextension))
                {
                  
#how do i show an error to the user?.. in a presentable way
                
return false;
                }
        }
}

?>
PHP Code:
my form
---------------------------------------------------
<?php
include("imageClass.php");


if(isset(
$_FILES["file"]) && !empty($_FILES["file"]))
{
$upload serialize($_FILES["file"]);
$image = new image("$upload");
}

else
{
?>
<form method="post" enctype="multipart/form-data" action="<?php echo
$_SERVER['PHP_SELF']; ?>" >
<input type="file" name="file" /><input type="submit" value="Upload"/>
</form>

<?php ?>
I am looking at try and catch but couldn't understand how to show it to the user in a more customizable way(can be use with css).
Thanks in advance!

Last edited by kokjj87 : 10-01-2008 at 01:58 PM.
kokjj87 is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:09 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design