Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7014673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:33:07+00:00 2026-05-27T22:33:07+00:00

I can easily upload the files into the database But when i want to

  • 0

I can easily upload the files into the database But when i want to edit the files,I am getting Undefined error. Here is the code:

product_update.php This is where i am able to modify all the existing information of particular records in the database.

<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="purchase_try"; // Database name 
$tbl_name="product_list"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");


// get value of id that sent from address bar
//$id = $_GET['AutoID'];

if(isset($_GET['AutoID'])){
$id= $_GET['AutoID'];
}
// Retrieve data from database 
$sql="SELECT * FROM $tbl_name WHERE AutoID = ".$id;

$result=mysql_query($sql);

$rows=mysql_fetch_array($result, 1);

?>


            <form name="form1" method="post" action="update_post.php"/>
            <table width="600" border="0" cellspacing="1" cellpadding="0">

            <tr>
            <td>
            <table width="100%" height="87" border="1" cellpadding="3" cellspacing="0">
            <tr>
            <td colspan="3"><table width="100%" height="87" border="1" cellpadding="3" cellspacing="0">

            <tr>
            <td align="center"><strong>Title</strong></td>
            <td width="144" align="center"> : </td>
            <td > <input name="title_product" type="text" id="title_product" value="<?php echo $rows['title_product']; ?>" size="90" /></td>
            </tr>

            <tr>
            <td align="center"><p><strong>Description</strong></p></td>
            <td align="center"> : </td>
            <td><input name="description_product" type="text" id="description_product" value="<?php echo $rows['description_product']; ?>" />
            </td>
            </tr>

            <tr>
            <td width="169" align="center"><p><strong>Start Date</strong></p></td>
            <td align="center"> : </td>
            <td><input name="start_date" type="text" id="start_date" value="<?php echo $rows['start_date']; ?>" size="40" /> </td>
            </tr>

            <tr>
            <td width="169" align="center"><p><strong>End Date</strong></p></td>
            <td align="center"> : </td>
            <td><input name="end_date" type="text" id="end_date" value="<?php echo $rows['end_date']; ?>" size="40" /></td>
            </tr>

            <tr>
            <td width="169" align="center"><strong>Price Before</strong></td>
            <td align="center"> : </td>
            <td> <input name="price_before" type="text" id="price_before" value="<?php echo $rows['price_before']; ?>" size="40" /> </td>
            </tr>

            <tr>
            <td width="169" align="center"><strong>Price After </strong></td>
            <td align="center"> : </td>
            <td> <input name="price_after" type="text" id="price_after" value="<?php echo $rows['price_after']; ?>" size="40" /> </td>
            </tr>

            <tr>
            <td width="169" align="center"><strong>Percentage </strong></td>
            <td align="center"> : </td>
            <td><input name="percentage" type="text" id="percentage" value="<?php echo $rows['percentage']; ?>" size="40" /></td>
            </tr>

            <tr>
            <td width="169" align="center"><strong>Edit Uploaded Images?<!-- <a href="image_edit.php?AutoID=<?PHP //echo $rows['AutoID'];?>">Click here.</a> --></strong></td>
          < <td align="center"> : </td>
            <td><input name="ufile1" type="file" id="ufile1" size="50" /></td>
            </tr>

            <tr>
          <td width="169" align="center"><strong>Image 2 </strong></td>
            <td align="center"> : </td>
            <td><input name="ufile2" type="file" id="ufile2" size="50" /></td>
            </tr>

            <tr>
            <td width="169" align="center"><strong>Image 3 </strong></td>
            <td align="center"> : </td>
            <td><input name="ufile3" type="file" id="ufile3" size="50" /></td> 
            </tr>

            <tr>
            <td width="169" align="center"><strong>Date Created</strong></td>
            <td align="center"> : </td>
            <td><input name="date_created" type="text" id="date_created" value="<?php echo $rows['date_created']; ?>" /> </td>
            </tr>

            <tr>
            <td width="169" align="center"><strong>Time Created</strong></td>
            <td align="center"> : </td>
            <td><input name="time_created" type="text" id="time_created" value="<?php echo $rows['time_created']; ?>" /></td>
            </tr>

        <td colspan="3"><p align="right">
        <input name="AutoID" type="hidden" id="AutoID" value="<?php echo $rows['AutoID']; ?>" />
        <input type="submit" name="Submit" value="Submit" />
        </p></td>
        </tr>
        </table></td>
</tr>
</table>
</td>

</tr>
</td>
</form>

<?php

// close connection 
mysql_close();

?>

then, Update_Post.php This File takes all the Values of the FORM and UPDATES the database. Other fields are updated BUT the FILE UPLOAD doesn’t work. It gives error.

<?php
$host="localhost"; // Host name 
$username="root"; // Mysql username 
$password=""; // Mysql password 
$db_name="purchase_try"; // Database name 
$tbl_name="product_list"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");
// update data in mysql database

?> 
<?PHP
 if(isset($_POST['Submit'])) 
    {



    $title          = $_POST['title_product'];
    $description    = $_POST['description_product'];

    $start_date     = $_POST['start_date'];
    $end_date       = $_POST['end_date'];
    $price_before   = $_POST['price_before'];
    $price_after    = $_POST['price_after'];
    $percentage     = $_POST['percentage'];

    $image_1        = $_FILES['ufile1']['name'];
    $image_2        = $_FILES['ufile2']['name'];
    $image_3        = $_FILES['ufile3']['name'];

    $date_created   = $_POST['date_created'];
    $time_created   = $_POST['time_created'];

    $id                 = $_POST['AutoID'];

    $sql="UPDATE $tbl_name SET title_product='".$title."',
                                    description_product='".$description."',
                                    start_date='".$start_date."',
                                    end_date ='".$end_date."',
                                    price_before='".$price_before."',
                                    price_after='".$price_after."',
                                    percentage='".$percentage."',

                                    date_created='".$date_created."',
                                    time_created='".$time_created."' WHERE AutoID=".$id; 

    $result=mysql_query($sql);
//  image_1 = '$image_1',
    //                              image_2 = '$image_2',
    //                              image_3 = '$image_3',

    //$sql_insert = "INSERT INTO $tbl_name(image_1, image_2, image_3)VALUES ('$image_1', 'image_2', 'image_3') WHERE AutoID= ".$id;

    //$sql_result = mysql_query($sql_insert);
    // if successfully updated. 
    if($result){

                    $path1= "upload/".$_FILES['ufile1']['name'];
                    $path2= "upload/".$_FILES['ufile2']['name'];
                    $path3= "upload/".$_FILES['ufile3']['name'];

                    //copy file to where you want to store file
                    copy($_FILES['ufile1']['tmp_name'], $path1);
                    copy($_FILES['ufile2']['tmp_name'], $path2);
                    copy($_FILES['ufile3']['tmp_name'], $path3);
                    //$_FILES['ufile']['name'] = file name
                    //$_FILES['ufile']['size'] = file size
                    //$_FILES['ufile']['type'] = type of file

                    // Use this code to display the error or success.

                    $filesize1=$_FILES['ufile1']['size'];
                    $filesize2=$_FILES['ufile2']['size'];
                    $filesize3=$_FILES['ufile3']['size'];

                    //all 3 must be selected to upload.
                    if($filesize1 || $filesize2 || $filesize3 != 0) 
                    {
                    $sql_insert = "INSERT INTO $tbl_name(image_1, image_2, image_3)VALUES ('$image_1', 'image_2', 'image_3') WHERE AutoID= ".$id;

                    $sql_result = mysql_query($sql_insert);
                    echo "We have recieved your files";
                    }

                    else {
                    echo "ERROR.....";
                    }
                    echo "Successful";

                    //header("location:user_history2.php");
                    } 
    }

    else 
    {
    echo "Update Unsuccessful.";
    }

?>

The is Undefined index : ufile
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:33:08+00:00Added an answer on May 27, 2026 at 10:33 pm

    Your form needs the enctype="multipart/form-data" attribute to be able to upload files.

    More information here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When using PyWin I can easily load a python file into a fresh interactive
Apparently you can easily obtain a client IP address in WCF 3.5 but not
Can anybody give an example of c++ code that can easily convert a decimal
I'm looking for a technology that can be used to upload large (~2GB) files
I'm trying to upload a file using ActionScript, which I can do quite easily
I have a web application with an upload form where users can upload files.
I am building a php application. I can easily upload an image or any
I am using Jquery ajax to Upload files to my database to produce a
I have a WordPress site, in which type1 users can upload *.doc files and
I can easily define a datatype for a node of a directed graph. data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.