Jump to content

Edit Image


ayok

Recommended Posts

Hi,

I have scripts that are used to update datas from database. So it shows the datas on the browser, change, and update it. But I have problem with updating the image.

 

Here is my update.php:

<?php
$fupload = $_FILES['fupload']['tmp_name'];
$fupload_name = $_FILES['fupload']['name'];
$category = $_GET['category'];
$title = $_GET['title'];
$descript = $_GET['descript'];
$price = $_GET['price'];
$id = $_GET['id'];
include "../../connection/db.php";

$input=mysql_query("UPDATE products SET title='$title', category='$category', descript='$descript', price='$price', image='$fupload_name' WHERE prod_id='$id'") or die(mysql_error());

$direktori_file = "../../images/products/original/$fupload_name";

if (!move_uploaded_file($fupload, "$direktori_file"))
{
    echo "Upload failed!<br>";
    echo "<a href=add_pic.php>Upload again!</a><br>";
}

elseif ($input)
{
    echo "input data success!<BR>";
    echo "<a href=add_pic.php>Add again</a><br>";
    echo "<a href=../logout.php>Logout</a><BR>";
    echo "<a href=index.php>Cek Products</a><BR>";
}
else
{
    echo "Input process failed!";
}
.........
?>

 

With this script, I can update the data's, except the image. Is there anyway i can update the image?

 

Thank you.

ayok

Link to comment
Share on other sites

Hi Barand,

 

No.. with $_GET, the table is updated (except the image -> becomes blank), with $_POST nothing's happened.

What doesn't work is the image isnot uploaded. And I have "enctype='multipart/form-data'" in the form tag. perhaps I need to change $_file?

 

Thanks,

ayok

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.