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
https://forums.phpfreaks.com/topic/230990-upload-image-in-php/#findComment-1189050
Share on other sites

I used a little known technique to find this:

http://php.about.com/od/advancedphp/ss/php_file_upload.htm

What I did was to type “php upload script”  into a secret search engine called Google. Please keep this information secret otherwise people will use it and it will get overloaded, break and I won't be able to use it any more.

 

Link to comment
https://forums.phpfreaks.com/topic/230990-upload-image-in-php/#findComment-1189051
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
https://forums.phpfreaks.com/topic/230990-upload-image-in-php/#findComment-1189062
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.