0

I'm using CakePHP 2.0.4, PHP 5.3.1, Apache 2.2.14.

For example: the filename is F#7m7~1.gif. It really exists, the path and filename are correct.

Before print HTML tag, I encode it by using urlencode() and the tag goes like:

    <img src="/chord/img/chords/F%2523m7~1.gif" alt="F#m7">

But the image is not loading. ('Chord' is a CakePHP Plugin)

I also tried to load it directly on the browser, http://myapp.localhost/chord/img/chords/F%2523m7~1.gif but what I get is: "Missing Controller Error: Chord.ImgController could not be found."

Everything works fine with the file as A~1.gif, but it brokes with filenames such as F#m~1.gif, B(7)~1.gif etc.

Everthing was working ok in pure PHP coded version. Now, it's not working at CakePHP.

Is there anybody have a clue?

thicolares
  • 295
  • 3
  • 14
  • The easiest fix is to just not allow filenames with unusual characters in them. Best to stick to [a-zA-Z0-9\._-] – GordonM Jan 01 '12 at 18:41
  • GordonM, I believe you're right. But since it was workin in pure php version, I realized that was possible to work also in CakePHP. By the way, the images filename are automatically generated, then I can refactor the engine to generate this way. But I really want to know why just does not work well. If I give up on the way, I'll let you know! hehe – thicolares Jan 01 '12 at 20:55
  • Well, thanks for reply, folks. I chose to redo the name of the images (its a script), friendly this time. For the record, I've found this nice link about this issue: http://playground.zaplabs.com/sandbox/qa/stackexchange/serverfault/295664/. But I believe it's an unecessary overhead for my situation. – thicolares Jan 02 '12 at 23:46

1 Answers1

0

You seem to be double-encoding it, the right urlencode for F#7m7~1.gif is F%237m7~1.gif, not F%2523m7~1.gif. Just remove one of them.

The Missing Controller error is just because there is no such file on your server, so Cake thinks you're trying to call an ImgController, within the Chord plugin. Try http://myapp.localhost/chord/img/chords/F%237m7~1.gif, it should work.

Anyway, as @GordonM pointed out, it's best to stick with normal characters for filenames.

luchomolina
  • 1,202
  • 2
  • 13
  • 24
  • Hi! Thanks for reply! Good point! But I've tried also with one encode, event without encode, and still it did not work. – thicolares Jan 01 '12 at 21:01
  • So you're saying that when you load this http://myapp.localhost/chord/img/chords/F%237m7~1.gif on your browser it doesn't work? – luchomolina Jan 01 '12 at 22:03
  • Yes, it doesn't work. Oh, and the example is F#m7~1.gif I've tried http://myapp.localhost/chord/img/chords/F%23m7~1.gif – thicolares Jan 01 '12 at 22:16