Re: creating and viewing an image database

2006-08-24 Thread francky06l

I have used the fileinfo (finfo_open / finfo_file) php functions to
check the mime type of the uploaded file.
I check for the MIME type detected into a list of valid mime I can
store in DB.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: creating and viewing an image database

2006-08-07 Thread JP

Cheers, thats great,
in fact I recycled some code from a tutorial on the cake wiki
(http://wiki.cakephp.org/tutorials:beginners_only) to do what i wanted
fairly sucessfully.
I have another question regarding the safety of letting users upload
content to my database, as it seems a fairly risky business if you get
it wrong!
Firstly i check if the uploaded file exists and is a photo with
 if ($file = $this->params['form']['userfile'])
and
 if ((is_uploaded_file($file['tmp_name'])) and ($filedetails =
getimagesize($file['tmp_name'])))

Then I get the filestype to store in 'ext' by
$filename = $file['name'];
if (($pos = strrpos($filename, ".")) === FALSE) {
$this->Picture->invalidate('no_file');
} else {
$this->data['Picture']['ext'] = substr($filename, $pos + 1);
}
I then validate 'ext' in Picture.php using regex
'/^(?:jpg|jpeg|gif|png)$/i'
so that upload into the databse will be prevented before
$this->Picture->save($this->data)
It is a bit of a belt and braces approach, but is it safe?
would a non-picture file be able to still be uploaded to the temp
directory, and will it be able to execute if it was mailicous?
when should i read the file content into the database, and when would a
malicous piece of code be executed if it was uploaded sucessfully?
would it be when the "image" was viewed again?
Sorry for all the questions!
Cheers,
JP


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: creating and viewing an image database

2006-08-06 Thread ryanb006

Oops. Forgot the link. :-)

http://groups.google.com/group/cake-php/browse_thread/thread/61ad2bd1f87fc4c/c25a9b511476fdd2

Ryan


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: creating and viewing an image database

2006-08-06 Thread ryanb006

Either way you do it (database storage or file system storage), check
this thread for some generic file download code with header output and
turning off rendering, etc.  If you want to use these images as content
images on your site (i.e. the img src is like
"/cake/pictures/myimagefilename.jpg"), then you'll need to remove the
content-disposition: attachment header line because that should make it
a "download" and prompt the user to save the image.

HTH,
Ryan


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



Re: creating and viewing an image database

2006-08-05 Thread Dr. Tarique Sani <[EMAIL PROTECTED]>

JP wrote:
> I would like to make an image upload and view database, storing the
> images in the file system isn't really practical for my project.
care to elaborate why it is not practical to store images on the file
system? (in your case of course)

Cheers
Tarique


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---



creating and viewing an image database

2006-08-05 Thread JP

I am a bit of a beginner to cakePHP, tried RoR but couldn't find decent
hosting so thought I'd give PHP a go.
I would like to make an image upload and view database, storing the
images in the file system isn't really practical for my project.

I read the great cakebaker article on uploads
(https://cakebaker.wordpress.com/2006/04/15/file-upload-with-cakephp/)
and have a much better grasp of that now, but how do I output the blob
data stored in the database as an image in a view?

Cheers, JP


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~--~~~~--~~--~--~---