I have a form which has action="process.php". Inside that php file there is a function followed by some code which calls the function, like this:
function uploadImage($fileName, $maxSize, $maxW, $fullPath) {
// .... does stuff
}
$filename = strip_tags($_REQUEST['filename']);
$maxSize = strip_tags($_REQUEST['maxSize']);
$maxW = strip_tags($_REQUEST['maxW']);
$fullPath = strip_tags($_REQUEST['fullPath']);
if($filesize_image > 0){
$upload_image = uploadImage($filename, $maxSize, $maxW, $fullPath);
}
I want to use this code in a cakephp app which requires me to cakeify things by turning it into controller actions.
I thought I’d be able to sperate the function into a seperate action and create another function with the other code that calls the first function in it, ie:
function uploadImage($fileName, $maxSize, $maxW, $fullPath) {
//.... does stuff
}
function calluploadImage() {
$filename = strip_tags($_REQUEST['filename']);
$maxSize = strip_tags($_REQUEST['maxSize']);
$maxW = strip_tags($_REQUEST['maxW']);
$fullPath = strip_tags($_REQUEST['fullPath']);
if($filesize_image > 0){
$upload_image = uploadImage($filename, $maxSize, $maxW, $fullPath);
}
}
and then make the form’s action just action="calluploadImage" but that returns the error:
Fatal error: Call to undefined function uploadimage() in
C:\xampp\htdocs\cakephp\app\controllers\campaigns_controller.php on
line 102
Can someone help me out? 🙂
You are calling uploadImage withour
$this->replace
to: