1

Hi I'm new to PHP and CodeIgniter and I have the following problem

I have a controller in which I want to call a PHP funnction that is defined on another .php.

This is the function:

function createNote($note_text){
     header('Content-type: image/jpeg');
     $note = "./application/controllers/notes/note.jpg";
     $rImg = ImageCreateFromJPEG($note);
     imagejpeg($rImg);

    //After this I want to use the "imagettftext" function to insert the $note_text in
    //the image   
}

This is suposed to load that image and show it (I guess) but it doesn't, instead it shows the following:

enter image description here I know the path to the image is correct because if I change it the ImageCreateFromJPEF returns an error saying that the image was not found...

Any ideas?

Thanks in advance!

3
  • 1
    Can you also show us what your .htaccess file looks like at the root of your site? Commented Sep 4, 2012 at 23:39
  • is that Problem solved. If solved how ? Commented Dec 1, 2013 at 9:01
  • @Ts8060 check this answer stackoverflow.com/questions/1397014/… Commented Dec 2, 2013 at 2:13

2 Answers 2

1

Troubleshooting tips:

  1. You should check the output to ensire that you're not adding any characters before or after the ouptput.
  2. Add "exit" after the imageJPEG() to prevent further execution (it'll look for a view somewhere).
  3. Do a var_dump($rImg) and view (as normal file, comment out the header line) to check the image object is being loaded correctly. As Umair said in comment, use an absolute path or base of application root to make sure you are loading the file in correctly.
Sign up to request clarification or add additional context in comments.

Comments

0

After VictorKilo answered I searched how to set the .htaccess file.

This question helped me a lot: How do I write a .htaccess file to make CodeIgniters URL routing work?

Before, my .htaccess had "Deny from all", now it looks like this:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|stylesheets|scripts|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Hope this helps someone else. Thanks for your time and answers Umair Iqbal, VictorKilo and Robbie.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.