I have created a basic website that uses MySQL and PHP to store the pages in a database following some online tutorial. The pages are used to dynamically create the menu , which I like. The main point of the site is to be an online gallery of paintings.
I can easily create this site statically in HTML, but I kind of want to try doing it dynamically. I can store the jpegs in a folder on the server and have HTML links within the page content. But is there any other way of doing it? Would it be sensible to store all the picture data and file names in a database, so that it gets retrieved when a user clicks an option from the menu?
Any thoughts would be appreciated
Research a bit more, you have one of the most answered problem in existence.
Why do you want to do it dynamically if static HTML is sufficient for your use. To make it cool is not the right reason.
About storing the jpegs in database read this article.
To BLOB or Not To BLOB - Microsoft Research
research.microsoft.com/apps/pubs/default.aspx?id=64525
Related
I have made a small html website which uploads your video onto my website, by saving the video reference in mySQL and displaying all files in the database on a website, I have done this successfully, but I am not able to play videos in realtime like YouTube, i need to download the video aand view it on my own desktop player... I wish to in a way stream the URl from the database playing on the website ... if that makes sense!
Thank you fellow Community Members.
Provide some more data please. Like what path do you use, etc.
I am trying to create a php page that reads a list of films from a database and displays the corresponding images in a table.
I've found quite a few examples of this, but havent successfully been able to implement it yet.
Has anyone got a link to a good tutorial on doing this or perhaps code you've used yourself?
so my images are stored in a folder 'images' on a server, and each entry in my table contains the colulmn 'imagelocation' which has a relative location, like "images/film1.jpg".
Ultimately the images will be clickable and will open a lightbox type view with the image and full info about the film.
any help appriciated!
I am in the process of building a CMS using php, however I am struggling on how to handle the various different assets that a dynamic page could serve, typically an average page will contain pictures of various sizes(thumb, body, main, etc), inline images and various different assets(pdf, flv, mp4, doc, etc).
At the moment a user can upload assets and create a folder on the server, I just wanted some techniques and concepts on how to manage this in terms of deleting, editing and linking to my dynamic pages within the cms? I already have a content table which contains all the content(meta_stuff, title, friendly_url, content_text, etc).
On upload should a reference be stored somewhere in say a asset table?
Should all paths to assets(images, docs, videos,etc) be stored in one table? or separate for each asset?
Should multiple image sizes(small, medium, large, etc) be stored in different fields e.g(assetid, smallpath, mediumpath, largepath?
What technique to use to link assets to the dynamic page? should this be a joined table or single? how do I go about retrieving the different assets for a page several pdfs and several images?
How to handle deleting of assets as this could be referenced to another dynamic page?
and anything else you think would be beneficial?
Thanks for all your help
Here are some basic things to keep in mind when dealing with resources (videos, images, documents..) in a scenario similar to what you're describing.
You'd want is to know what's being uploaded, what kind of stuff are being uploaded and who's uploading. To do that, it's good to have the following tables:
Edit: Sorry about the mistake, asset_types.asset_type_id should be linked to assets.asset_type_id and NOT assesst.asset_id
(Note: This is just an outline, of course you'll have more fields)
This model makes it easy to do the following tasks
Upload: When something is uploaded, you store it somewhere (with the correct
.htaccess configurations) then store that path in the table.
Delete: When the user is trying to delete something, you check if he's the owner.
When you want to add a new type, you don't need to create a new table.
Hopefully this will put you in the right direction.
Update: Answering your comment, when a user wants to add an image to an article for example, you have two options here:
The user is presented with a button/select menu/whatever to choose the desired image, once clicked it will add <img src=LINK_TO_RESOURCE" /> to the body of the content (Make sure you protect yourself from XSS).
OR
You use your own simple markup, when the user clicks on an image this [[PREFIX_IMG:IMG_ID]] will be added to the body of the content, when the content is viewed you'll replace that "tag" with <img src="LINK_TO_RESOURCE" /> which you've acquired using IMG_ID.
2nd Update: Well you have a couple of options to handle resources that aren't directly embedded in the "articles" themselves.
You can have a field in the "articles" table you can call summary for example, and one more column to the assets table which you can call asset_sub_type and have different types like summary. Then when you want to view the summary you fetch the summary text/title from database and you add the resource to it.
(This is the technique I use) When fetching the summary from the database I see which image is the database that is related to that article and the resize it on the fly with PHP and append it to the summary.
I am building a webpage using PHP to search within my database. I am able to do a query and get the data to show on my page.
I also have a picture that is related to each record. Let's say something like a picture ID for each employee. I am wondering what is the best way to store and retrieve pictures in order to get it show using PHP.
Is there a way to store all the pictures in the subfolder like " image" and retrieve the pictures using PHP? I tried to search around on the internet, but I get confused.
Also, when I type something in the search box and click the button, is there a way to keep the input in the search box without erasing it?
Thank you very much.
The typical way is exactly what you said - store all the pictures in a folder and store their path in the database (or be able to build their path from their id or something). You just need to create a script to insert the record into your database when you add the picture to the file system.
You can store the pictures in database itself. You can have a field in the user table called 'pic' with data type 'blob'. This can store the image for every user. This link will get you started:
http://mrarrowhead.com/index.php?page=store_images_mysql_php.php
As, correctly pointed out by #shaheer in the comment below, this is not a recommended practice.
'Attaching' images to your class objects by storing the web-url in the database as a attribute of that class is a better way. There is a excellent Ruby gem that I use for this frequently its called Carrierwave. Its workflow should be good for you to get Idea on how to do this in php.
I am not sure if there are any good alternatives for php (I am not a php dev) but a quick search returned this: Attachy. This is specifically to manage 'uploads', but you can use the same technique on existing images that you want to attach to your class.
My app is posting to users' Facebook walls, and linking to a page they have created. The page is in html. I'd like to be able to put a thumbnail of the page as the image on the wall post. I'm not sure whether this is possible or not. Anyone have any ideas?
If it helps, the page itself is stored as a series of 'elements'... for each one, I know the size and position of the element, and the content (which may be text or an image). So I can pull all that in from the database.
I guess it would be sufficient to create a thumbnail using php at the point when the user clicks 'Publish This to my wall', if that's easier than doing it on the fly - I can save the image and then link to it.
Any ideas?
I create thumbnails for my site using CutyCapt, which works very well indeed on both Windows and Linux. You can use exec to invoke this from php.
There are also web services that allow you a quota of free thumbnail snapshots, that are easy to integrate into your website. e.g.
http://www.websnapr.com/
or
http://webthumb.bluga.net/home
I figured out how to do this. I used the PHP gd library, which allows you to create a base image and then add images and text. Works pretty well.