How to take image as an input

Hey everyone! i am creating a form in which i want to take image as an input and save it in the database. I want to save the image name in the database and the image file in a particular folder.

How can i do it plz help me…

promo.php
[php]

RegistrationForm
Username


Enter Image

REGISTER
[/php]

promotion.php

[php]

<?php include "config.php"; session_start(); $username=$_POST['uname']; $image=$_POST['image']; $insert="INSERT into promotion(username,image) VALUES('".$userno."','".$image."')"; if (mysql_query($insert)){ echo "added"; } else echo "Error"; ?>

[/php]

for the image look at the $_FILES global array rather than the $_POST one:

http://uk3.php.net/manual/en/reserved.variables.files.php

You can also store the file in the database using a blob field. Just google it you will find plenty of instructions. People do it a lot with MP3s as well.

Sponsor our Newsletter | Privacy Policy | Terms of Service