Modx api how to use runSnippet?

Maybe just post an overview of the structure of your program here. All the functions and function calls and the parts where you instantiate or use $modx.

function tryUpload($file){
	...
	$modx->runSnippet('phpthumbof', array('input' => $avaLittle, 'options' => $options));
	...
}

function another_function(){
	initialize_modx();
	tryUpload();
}

function initialize_modx(){
	$modx = new modX();
}

Now at the beginning of tryUpload function I use global $modx; Thank you Bruno17. I get the same error. I’ve changed phpthumbof to units to check if I get the same error (units - is a component for Russian language) and there was no error. Does it mean that something wrong with phpthumbof?

After submitted the form I checked the directory assets/components/phpthumbof/cache/ and I found the image I have upload. So phpthumbof works fine. Then what’s the problem?

As halftrainedharry said, it really looks like you either are not creating (instantiating) the $modx object properly, or the $modx variable is not available where you’re trying to use it.

As a general practice, I always instantiate modx once using the code here, check it with instanceof, then pass it as an argument to any function that needs it.

SOLVED

Hello guys.
Thanks everyone very much. Thanks for your advices. Thanks to you I solved the problem. Everything was fine with API. The problem was that phpthumbof didn’t like the link of the file. No matter absolute link or local link. I don’t know why and I don’t even want to know.

I installed phpthumbsup, didn’t change the code and the snippet worked just fine.

If your problem is same, try to install phpthumbsup