Jump to content

Saving Name To Database.......


arunpatal

Recommended Posts

Hello everyone...

 

I am able to upload the image to server but how can i save the image name to database in field call product_image1 ...

 

here is uploading script

 

<?php
if (isset($_FILES["product_image1"])){
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["product_image1"]["name"]));
if ((($_FILES["product_image1"]["type"] == "image/gif")
|| ($_FILES["product_image1"]["type"] == "image/jpeg")
|| ($_FILES["product_image1"]["type"] == "image/png")
|| ($_FILES["product_image1"]["type"] == "image/pjpeg"))
&& ($_FILES["product_image1"]["size"] < 1024000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["product_image1"]["error"] > 0)
{
echo "Return Code: " . $_FILES["product_image1"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["product_image1"]["name"] . "<br>";
echo "Type: " . $_FILES["product_image1"]["type"] . "<br>";
echo "Size: " . ($_FILES["product_image1"]["size"] / 1024000) . " kB<br>";
echo "Temp file: " . $_FILES["product_image1"]["tmp_name"] . "<br>";
if (file_exists("upload/" . $_FILES["product_image1"]["name"]))
 {
 echo $_FILES["product_image1"]["name"] . " already exists. ";
 }
else
 {
 move_uploaded_file($_FILES["product_image1"]["tmp_name"],
 "upload/" . $_FILES["product_image1"]["name"]);
 echo "Stored in: " . "upload/" . $_FILES["product_image1"]["name"];
 }
}
}
else
{
echo "Invalid file";
}}
?>

 

 

Here is form

 

form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1" enctype="multipart/form-data">
<input type="file" name="product_image1" value="" size="32" />
<input type="submit" value="Add Product" />
</form>

Link to comment
https://forums.phpfreaks.com/topic/272532-saving-name-to-database/
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.