Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

I have a very urgent problem with accessing images

After user uploads images, i move them to public/img.

I need to access them free through url like: www.mysite.com/api/v1/public/img/image.jpg So the user can see it.

The problem is that when I do that i get this line of error:

ImgController handler class cannot be loaded

I'm in a very very hurry because we lunched the app and last night i moved it to other server and is not working now. Thank you so much!



7.2k

If you move ing to public/img - you can find it in url "/img" maybe (see setup your server)

<img src="/img/image.jpg">


5.6k
edited Jun '14

.htaccess / mod_rewrite configuration issue?

Depending on that setup stuff gets probably rewritten to your index.php If you're using something like what's documented in Phalcon's installation instructions, requests get rewritten when there's not a directory or a file at that location (a very simple rewrite config).

So I guess the image simply doesn't seem to exist or is somehow unreachable? That's why your request get's rewritten to index.php, so Phalcon kicks in, processing your request.

ps: you 'lunched' the app? How was that like? :)) (sorry, just joking ;))

ps2: as a quick fix, you could add a .htaccess to your img folder, turning rewrite off: RewriteEngine Off Then users will get a 404 Not Found, instead of 'weirdness' :)

edited Jun '14

AddDefaultCharset UTF-8

<IfModule modrewrite.c> RewriteEngine On RewriteCond %{REQUESTFILENAME} !-d RewriteCond %{REQUESTFILENAME} !-f RewriteRule ^(.*)$ index.php?url=/$1 [QSA,L] </IfModule>

this is the .htaccess from public folder



5.6k
edited Jun '14

Yes, that's just like the example in the docs. See my ps2 in post above.

The images exists, but somehow it's searching for a controller to access it. I'm using amazon as serve and what i did was to copi the development instance to another account with the same configuration. On the development server it works perfect, but on this server I cannot access the pictures. The same config on both.

The images exists, but somehow it's searching for a controller to access it. I'm using amazon as serve and what i did was to copi the development instance to another account with the same configuration. On the development server it works perfect, but on this server I cannot access the pictures. The same config on both.

I tryed to add exactly as you sayd. It didn't worked. The problem is like this: if i go step by step in the url to that picture, from folder to folder it works, it finds it. But if I go directly, just copy and paste the entire url it doesn't work. Why would this happend?



5.6k
edited Jun '14

Did you try what I suggested? If that doesn't work the location simply doesn't seem publicly accessible.

api/v1/public is simply your document root right? (So end user request /img/image.jpg right?)

Are you sure you set this folder as the public folder? What kind of AWS service do you use exactly?

(edit: I just saw your response after posting this)



5.6k

Works for me?

I think you are wright... I cannot access only the picture I upload. The pictures that the user uploads. So it may be a persmissions problem? I'm using EC2 with ubuntu 12



5.6k

Are you sure you move your uploads to the right dir?



5.6k
Accepted
answer
edited Jun '14

Yes, should be right, as I don't see that img in the listing? http://{escape:md5(3389dae361af79b04c9c8e7057f60cc6)}**

edit: conceal url



5.6k

And you did try to add an .htaccess to that folder turning RewriteEngine off? (That should deal with the rewrites to index.php / Phalcon)



5.6k

You're welcome btw.

I am really sorry for not thanking you, we were so much in a hurry becouse we just launched a day before I posted in this forum and things didn't worked as expected. This is what happends when you are not experimented. And since the day we launched we had to work 24/7 so I completely forgot about what we discussed here. I know these are all excuses so I want to appollogise again for my bad manners.

Your answear really helped me! So please let me know if I can help you with something, I really owe you! Anything that will compensate your help!

Thank you so much for your time and I am really sorry for my bad education!



5.6k
edited Jun '14

Hi Andrei, thanks for your response!

Now I am feeling guilty, making you apologize like this... :P (You really are thanking me too much now.. ;))

It's not really that I especially need to be thanked or something, but I did wonder if/ how things worked out, and yes, I do dislike it when people seem to disappear after helping them, not letting know if things worked out etc.

But of course, there could / can be very valid reasons for that.. (And I certainly don't/won't rule out I might be/have been guilty of the same thing... ;))

So thanks again!

(But I do think you should fix the fact it's an open-dir currently... (though it is interesting to see al those people who are uploading pictures of themselves.. ;))

And what I noticed is that your web-server doesn't serve a MIME type (Content-Type) with those images.. That might give you troubles in some cases (especially since your files aren't named .jpg?))

You having holidays today as well? Enjoy it!

Hi Renskii.

Yes we are having some kind of holiday in my home country, but I currently live in Prague for a couple of mounths so here is not holiday... only work :)). Yes i believe it's interesting to see my users having fun :)). The problem is that I find access configuration a very complicated thing. I really don't know how to stop people accessing these photoes in browser but allow the acces from api calls. I prefer not to ruin everything right now, because we are having a couple of days before a pitch conference for investors that might be interested in us.

About that mime type I don't know what to say.. I really don't have a clear idea of what is that exactly but giving the fact that so far is working perfectly... until we will get a big investment I don't thing I should do something.

(about accessing my photoes, can you plese delete your comment with the link to them, I deleted mine all. A lot of people will se this, and I don't want to give them ideeas) :))

Enjoy this hollyday too and thank you for understanding!



5.6k

Andrei; I have edited my post.

Good luck with your project and pitch!