I am using the TimThumb script (http://code.google.com/p/timthumb/). My images links are generated like this: http://website.com/pics/nature/animals/bear.png and this works great but I can't seem to use TimThumb like this: http://website.com/resize.php?src=http://website.com/pics/nature/animals/bear.png&h=150&w=150, it says Could not find the internal image you specified. I believe this is because my images are brought from a folder by slug names (bear.png). The folder's images are named by the ID of the image so there is no bear.png on the server, my application is using slugs to search the DB and bring up the real name of the picture but it loads the image upon this link: http://website.com/pics/nature/animals/bear.png. If I give my resize.php script a link from flickr it works great.
BTW, resize.php is the actual TimThumb script.
Any ideas ? Thanks !
Dont use a local path, enter the full URL for timthumb just like you did with flickr
Related
I have successfully uploaded an image in folder application/uploads codeigniter. When I'm trying to display the image in an <img> tag its not showing. I've checked the path is correct and the image does exist.
Just hit that image src link on browser and check whether image is displaying or not. You can upload your images in assets folder. Call your image by using url https://yoururl.com/assets/imgfolder/img.jpg . It should display. Hope this will help you.
Can you show us the tag you are using with the path. If you believe the path is correct, can you type this path straight into your browser and see the image displayed? You can do a 'view source' to get the path if you are using Codeigniter base_url or similar.
(sorry to post this as an answer but my rep isn't high enough to allow commenting)
I have made a site with Codeigniter and users have options to upload their photos there. As the photos are personal, I think keeping them on web directory is not safe. As a result, I kept them on a root directory like /var/www/images directory. Now, how I can get the images in a webpage?
Wrong Choice dear learner. you images folder needs to be accessible by your code and to the browser to render that image by the image path. For example
This is the image directory of my project. I am using all these images in different pages of my website. Some are selected dynamically by my code.
Now in your case by putting images in www folder, you are making a path of http://images/ which is not recommended by any PHP guidelines. Your images folder should be in your project root not outside.
If you want to disable folders to be viewed, just add empty index.html file, but if you try to protect images from being viewed then your website wont be able to find them too image protection in codeigniter
The code will be as safe as you make it. Well what you are doing is fine, the web server will still have to access the images.
While ignoring the rest of your code or what yo are trying to achieve, you could try referencing the images fro your webroot or probably create a symlink.
Also, I would try to put the images in another place like AWS.
If security is a concern for you, you can try building a ImagesController that checks if image exists, if user has permissions to see it and after that render it.
Uploaded images should also have some reference row inside a table in your database that can have a column which specifies if it should be public (also try to sort them to folders depending on what it represents - user profile pics, product images, etc).
I know it's a little bit of work but this would be the way I would do it.
You can check online for examples of controllers that return an image.
Good luck on your project.
In one of my work i need to build a feature for users to upload videos. i m creating a directory if not exists for that user and storing videos into it. I did directory listing off in .htaccess file so in this case no one can access files listing directly from url.
But when anyone can play that uses video, embed code is generated and in that path is also displayed for that video. When i copy and paste that path in url , video gets downloaded. i want to prevent it from directly accessing? can anyone has a solution for the same?
https://tn123.org/mod_xsendfile/
I use this
You can store your video files not in DOCUMENT_ROOT directory and provide access through the program.
Something like this: http://test.com/watch.php?video_id=blahblablah , like Youtube
I have a download.php file to display images on a web page as well as downloading files like pdfs, docs, etc.
in ckeditor if the src for the image is /download.php it dispalys like there is no image or broken link image, if the src for the image is http://www.mydomain.com/download.php my image displays just fine in ckeditor.
Any thoughts? And no i cant just make it put the full domain. There is a reason to long, complicated, and stupid to explain thanks to the web hosting company.
In the configuration you need to set the baseHref to the full path, then it will add that to the images/files you upload and insert.
In my website people can upload their photos. And I show them. Is it possible, that they would not be able to see url where that image is?
Photos are shown like this <img src="http://mywebsite.com/my_images/image_name.gif" />. What I want to do, that people couldn't see that src link. Is there any way to show photos from that directory without exposing directory name?
Thanks.
There isn't, but you can use URL rewriting (apache's mod_rewrite or a custom PHP script to serve the images) to hide the actual location on your web server.
For example for the latter approach you coud have a serveimage.php on the server, which is called like serveimage.php?file=file1.jpg.
You can call another php-script via <img src="..."> the script loads the image and generates it. This FAQ entry should help.