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

  • Home
  • SEARCH
  • 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 7971693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:41:34+00:00 2026-06-04T07:41:34+00:00

I have a html form and i used it to upload a picture to

  • 0

I have a html form and i used it to upload a picture to server

    <form id="form1" name="form1" method="post" action="testimage.php" enctype="multipart/form-data" >   <table width="1000" border="0">
    <tr>
    <td width="108">ID</td>
    <td width="229">
      <input type="text" name="id" id="id" value="<?php if(isset($_GET['editcat'])){echo $_GET['editcat'] ;}; ?>" tabindex="1" />
   </td>
   <tr>
    <td>Image</td>
    <td>:</td>
    <td><input type="file" name="image" id="image" tabindex="7"  /></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>User</td>
    <td>:</td>
    <td><input type="text" name="user" id="user" value="<?php echo $user ; ?>" tabindex="8" /></td>
    <td>&nbsp;</td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td><?php if(isset($_GET['editcat'])){ ?> <input name="editcat" type="hidden" value="set" /> <?php }?> </td>
    <td><input type="submit" name="submit" id="submit" value="Add/Edit" tabindex="9" />                        </td>
    <td>&nbsp;</td>
  </tr>
</table> </form>

I retrieve this form data by a php file

       <?php session_start();
       $user_name = $_SESSION['username'];
       $user_pass = $_SESSION['password'];
       if ( $user_name == '' ) {
       header('location:login.php');
       exit();
       }
       ?>
       <?php require_once('connection.php');?>
        <?php require_once('function.php');?>
       <?php 
       $err = 0;
       if(!isset($_SESSION['msgback'])){
       $_SESSION['msgback'] = array();
       }else{
   unset($_SESSION['msgback']);
   $_SESSION['msgback'] = array();
       }
       if(isset($_POST['id'])){
   $id = $_POST['id'];
       }else{
   $id = "";
       }if(isset($_POST['user'])){
   $user = $_POST['user'];
       }else{
   $user="";
        }
       if(!empty($_FILES['image'])){
       $name= basename($_FILES['image']['name']); 
       move_uploaded_file($_FILES["image"]                                  ["tmp_name"],"Hants/admin/uploads/fron_sect/$name")or die(mysql_error());   
        }
         ?>
        <?php
        /////          
        if(isset($_POST['editcat'])){
     if($err == 0){
    if($_POST['id'] == ""){ $_SESSION['msgback'][] = "empty id"; }
        if(empty($_SESSION['msgback'])){
        $user_query = "
        UPDATE  
         pro_category 
        SET  
        `image`='$name',
    `update_user`='$user'
    WHERE  
        `id`='$id'";
        $user_result = mysql_query($user_query) or die(mysql_error());
    $_SESSION['msgback'][] = "Product category is updated sucesfully.";
    header('location:product_cat.php');
    }
   } 
    } 

    ////////Inserting a new Iteme////////
    if(!isset($_POST['editcat'])){ echo "editcat not set" ."<br/>";
   if($err == 0){ 
    if($_POST['id'] == "") {    
         $_SESSION['msgback'][] = "empty id";
        }
        if(empty($_SESSION['msgback'])){
          $user_query = "INSERT                            INTO `pro_category` (`section_id`,`category_name`,`description`,`position`,`visible`,`image`,`pro_view`,`update_user`) VALUES('{$secid}','{$catnam}','{$descrptn}','{$pstion}','{$visble}','{$name}','{$proview}','{$user}')
                                ";
$user_result = mysql_query($user_query) or die(mysql_error());
//if(mysql_affected_rows()){
//$_SESSION['user_name'] = $username;
$_SESSION['msgback'][] = "Successfuly Added";
header('location:product_cat.php');
                    //}
                }else{
                $_SESSION['msgback'][] = "Not Successfuly Added";
                    header('location:product_cat.php');
                //redirect_to("product.php?msgback=msgerr");
                    }
    }
}
?>

this code is working well when I select a image to upload. but in some cases i don’t need to upload the image but rest of the form field must uploaded in to the server. When i try to submit form without selecting a image it shows me a blank page and nothing happen.
i can’t figure it out where is the error is. if someone can help me.

  • 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-06-04T07:41:35+00:00Added an answer on June 4, 2026 at 7:41 am

    Update your code to add this check to see if a file was actually uploaded:

    if ($_FILES['image']['error'] == UPLOAD_ERR_OK) {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have a simple HTML Form <form id=uploadForm method=post action=/cgi-bin/test.cgi enctype=multipart/form-data> <input type=submit name=add_something
I have a HTML/PHP form using using post to send form data to a
I have an input form used for a forum, where users can post messages.
I have this : HTML : form + jquery Controller I post the form
I have an HTML form that previously was only used for text attributes for
I have used CakeDC users plugin. I need to upload/add a profile picture for
i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button
I have a following problem, I have HTML form that uploads a file with
My input tag started to go crazy... I have html form for input to

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.