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>

Edited by arunpatal
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.