PHP Tutorials: Uploading/Storing an Image inside a MySQL Database (Part 2)

Uploading and storing images inside a MySQL database, rather than as a file in a web directory. Visit the forum for help! phpacademy.info Follow on Twitter! twitter.com
Video Rating: 5 / 5
This will automatically upload, save and display a watermarked image. The user will upload an image, it will then be processed and an external watermark image will be placed in the bottom right hand corner. The watermarked image will then be saved and is ready to be used. FORUM phpacademy.org TWITTER twitter.com BLOG blog.phpacademy.org
Video Rating: 5 / 5
Related search terms:
upload image with php and store in mysql tutorial,uploading image in wordpress through php form,uploading images on a social system-Sourcecodes using PHP AND MYSQL,saving images to a database via php,PHP form Image upload Store in MySQL database video,PHP Tutorials: Uploading/Storing an Image inside a MySQL Database,mysql store images php design,facebook php sdk clear cache image,download free php script to watermark image and store in variable or in folder,upload image mysql php,upload image to database codeigniter,upload multiple image php,uploading and saving images inside the database using php/mysql,codeigniter image upload and store database,upload and resize image and save in mysql with php tutorial,upload an image into wordpress using php,storing and displaying images from mysql and php,store images in mysql database codeigniter,phpacademy watermark source code,php upload resize image,php upload image,php questions inside database,facebook php sdk upload image,wordpress form to mysql database
Related Posts On PHP Tutorials.net
You might also like
PHP Tutorials: Uploading/Storing an Image inside a MySQL Database (Part 1) Uploading and storing images inside a MySQL database, rather than as a file...
Do you know any free web hosting site that allows uploading of PHP files? Question by wingedfairy2004: Do you know any free web hosting site that allows uploading of PHP files? We...
How to move our Wordpress to Another Host via Database How to move our Wordpress to Another Host via Database Today i want to share, how to...
Does anyone know where I can find a tutorial explaining how to upload a file with php? Question by kiokushitaka: Does anyone know where I can find a tutorial explaining how to upload a file...
Can someone help me with uploading files using php? Question by annb: Can someone help me with uploading files using php? I am a beginner, I have some...

the quality is really bad, i uploaded a png, and it really sucks
Can anyone help me? I keep getting this two errors
Warning: file_get_contents() [function.file-get-contents]: Filename cannot be empty in C:xampphtdocsphpimageindex.php on line 26
Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in C:xampphtdocsphpimageindex.php on line 28
That’s not an image.
If you are fetching data you can use:
if( !numeric ( $id ) ) {
die();
} else
{
//code further..
}
as validation
AWESOME tutorial! I’ve created databases and file upload forms for years and learned (about form uploads) by piecing together so-called tutorials from Google results. This is by far the best tutorial EVER on this subject; not to mention that this is my first time viewing a video on it.
) You ROCK! I am now a subscriber to your channel.
AWESOME tutorial! I’ve created databases and file upload forms for years and learned (about form uploads) by piecing together so-called tutorials from Google results. This is by far the best tutorial EVER on this subject; not to mention that this is my first time viewing a video on it.
) You ROCK! I am now a subscriber to your channel.
Oh, does this work for uploading videos too?
@ti07shadow Yes, but addslashes has no idea what char set you use and can then be tricked into a sql injection, it also permanently adds the slashes which will force you to strip them.
And since they basically do the same thing mysql_real_escape suffers from the same problem and can be bypassed if your MySQL server or application doesn’t properly specify the char set to use(There is a function to do it, don’t use a SET NAMES query it won’t work), which a lot of people don’t.
@Myztik7 wel mysql_real_escape_string basically does the same thing as addslashes, its just more efficient than addslashes.
addslashes is for single-byte strings whilst mysql_real_escape_string is recommended for multi-byte strings.
… and it wooorks…
lol
@Myztik7
I agree with you, but PDO is not a good option for multi queries, only single queries.
There is also alot more work involved in say binding arrays. Some web hosts still use php4 so mysql is the only option for some.
My only real concern with this tutorial is there is no security against shell commands
@Hydrolics82
mysql_real_escape_string is much better, but like I said earlier, mysql_* functions are all old and still using them is pretty silly.. You should at least move up to the mysqli_* functions, or even better, use PDO.
And since mysqli and PDO isn’t ancient like mysql_* they support Prepared Statements which will let you separate the query and the data, that way the input data can’t modify the query and you get no sql injections.
Its about time!!!
@Myztik7
I agree real_escape_string will automatically addslashes then you would need to stripslashes when displaying. Images inside a database is also not really a good idea.
this is very good video!Thank’”s!!!
Thanks Alex for another really useful tutorial. This one had stumped me for ages!
Your tutorials should have so much more views, there that good
Probably using base64 makes the content 30% shorter
@phpacademy Hello, Alex. i have a question : What are the vid dimentions? (Bad English ;// ) is : 320×240 ? or what? (Sorry for my really bad english)
@phpacademy Yes, I did notice. The thing is, a PHP script isn’t all about functionality, but also about security. And nothing forbidden you to use the right functions.
Would have took a few less seconds even, because you edited your function twice.
@Morcous16 No it wouldn’t work, for a simple reason, the file will not be processed as an image but only as a standard PHP text file, which will only echo out some huge and strange string.
@phpacademy Will it still work without the header if you had refreshed your cache? Just wondering.
Thanks for a great tut Alex
@francismori7 I do mention in the tutorial it ’somewhat’ protects. I’m focusing on the functionality in this tutorial, rather than security.
Yeah, in regards to Myztik7, I’d recommend the use of mysql_real_escape which secures the string for MySQL input.
@Myztik7 It was a highly requested tutorial. Thanks for your input anyway.
Storing files in the database is slower and not really a good idea.
Also,
The mysql functions are pretty much deprecated and should not be used.
$_REQUEST is bad practice and should not be used unless you have a really good reason.
Using addslashes() is dumb and insecure.
Pssssssst, ever heard of the browser cache?
@francismori7 Thanks for letting me (and other viewers) know!
Finally you got partner videos of 30min !
@hinmatth You can see he’s on a tablet PC
Are you using a tablet PC? o.O
instead of using imagecreatefromjpeg which would only allow you or your users to upload images with the jpg or jpeg extension and has no way of checking wether the file is in fact a jpg/jpeg file.
use the imagecreatefromstring function in conjuction with the file_get_contents funtion which reads the file content into a string and then outputs the same data required.
$image = imagecreatefromstring(file_get_contents($location));
thanks for the tutorials. Keep up the good work.
hi alex
i want to make a feature which should tell me on a page bout the notifications from frnds n oder updates of account in a community website
thank you alottt,your videos are wonderfull
@phpacademy that would be awsome, ive been looking for a good tutorial for that since im making a script that includes such a feature.
Thanks Alex… great tutorial again
FUCK YOU!
@PGReviews worked for me
Thank you very, very much! Realy great
Most useful tutorial you’ve uploaded so far
Love it, and keep up the good work.
@cyrusxxx1 Uploading a video into a MySQL database is not a good idea. By doing this you’re storing a LOT of binary data, hence you’ll end up with a huge database file size. It would be better to upload the video to a file and use it that way. I may do a tutorial on uploading and playing videos in the future.
Alex can you make a tutoial that could upload Video into mysql in php and display it. I tried so many times to find a tutoial but I couldn’t find. please Alex…
please please alex I really need it.
@lifeg0eson666 I knew someone would be shouting at the screen. I’ve done it in the past, watching tutorials. Thanks for the feedback.
Thanks..!
Thank you
imagecreatefrompng?
nice!! i liked
Good tutorial. Great to see others make mistakes though haha. I almost shouted at the screen with the form method mistake.
A suggestion when using getimagesize() is to use list($x_pos,$y_pos) = getimagesize(‘image’);
Then do, $x_pos -= $watermark + 10; and same with $y_pos.
Also you could have used getimagesize() on the watermark image as well.
Great tutorial overall though, will surely help loads of people.
i love you man
Thanks so much.
absolutely awesome! thanks