Jump to content

Upload image in PHP


azizmuda

Recommended Posts

Hello everyone.i'm beginner in programming.How to make page that user can upload their own image..

 

my database

 

table:product

product_id (PK)

product_price

product_name

product_picture

 

anyone can help me..thank for advance:)

 

You can use a html form that passes a file using input type=file, then you insert into the db.

 

http://www.tizag.com/phpT/fileupload.php

 

Here is well explained.

Link to comment
Share on other sites

this my code....help me please.

this index file for insert the data.

<code>

<?php

session_start();

?>

<?php

$host = "localhost";

$username = "root";

$password = "";

$database = "upload_image";

$conn = mysql_connect($host, $username, $password) or die ("Could not connect");

$db = mysql_select_db($database, $conn) or die ("Could not select DB");

//query

?>

 

 

<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title> Dream in Code toturial</title>

<style type="text/css">

label

{

float:left;

text-align:right;

margin-right:10px

width:100px;

color:black;

}

 

#submit

{

 

float:left;

margin-top:5px;

position:relativve;

left:110px

}

#error

{

color:red;

font-weight:bold;

font-size:16pt;

}

</style>

</head>

<body>

<div>

<?php

if(isset($_SESSION['error']))

{

echo "<span id=\"error\"></p>".$SESSION['error']."</p></span>";

unset($_SESSION['error']);

}

?>

<form action="upload.php" method="post" enctype="multipart/form-data">

</p>

<label>First Name</label>

<input type="text" name="fname"/><br/>

<label>Last Name</label>

<input type="text" name="lname"/><br/>

<label>Upload Image</label>

<input type="file" name="image"/><br/>

<input type="hidden" name="MAX_FILE_SIZE" value="100000"/>

<input type="submit" id="submit" value="Upload"/>

</p>

</form>

</div>

</body>

</html>

 

 

 

 

 

</code>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.