Image not uplode in your ecommerce project in java. Plz provide me source code.

0 votes
asked Jul 5, 2016 in Java Web Application by Ajaykawane (320 points)

I like your ecommerce live project. And i put in my collage project. But when i do code as par your image upload video., i got an error that data not save.
Please provide me source code of your project so i can solve my error and put in my collage.
And i cant understand your language so please provide source code and video in english.
Waiting for your reply.
Yours student
Ajay

1 Answer

0 votes
answered Sep 16, 2016 by iqbal (340 points)
{<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>My E-commerce</title>
    <link rel="stylesheet" href="css/style.css" media="all" />
</head>
<body>

Image preload

<script>
function readURL(input) {
    if (input.files && input.files[0]) {
        var reader = new FileReader();
        reader.onload = function (e) {
            document.getElementById('preview').src=e.target.result;
        }
        reader.readAsDataURL(input.files[0]);
    }
}
</script>

main Container Satat

<div class="main_wrapper">
<?php 
SESSION_START();

if($_SESSION['email']){
?>
<div class="content_wrapper">

sidbar

<div id="login_sidebar">
<div id="sidebar_title">Account Information</div>

<?php
if(isset($_GET['edit'])){

$c_id= $_GET['edit'];

$name="select * from customer_register where id='$c_id'";

$run_name=mysqli_query ($con, $name);


    $row_name = mysqli_fetch_array($run_name);

$c_name= $row_name['name'];     
$c_image= $row_name['customer_image'];
$c_mobile= $row_name['mobile'];
$c_email= $row_name['email'];
$c_address= $row_name['address'];
}
?>

<img src="customer_image/<?php echo $c_image; ?>" width="200px" height="200px" alt="" /> 
  <div id="font">
<?php echo $c_mobile;?>
    <?php echo $c_email;?>
    <?php echo $c_address;?><br>
<li><a href="edit_profile.php?edit=<?php echo $c_id;?>" style="color:yellow; text-decoration:none;"><b >Update Profile</b> </a></li>
<li><a href="change_pass.php?page=<?php echo $c_id;?>" style="color:yellow; text-decoration:none;"><b >Change Password</b> </a></li>
<li><a href="recharge.php?page=<?php echo $c_id;?>" style="color:yellow; text-decoration:none;"><b >Mobile Recherge</b> </a></li>
<li><a href="bkash.php?page=<?php echo $c_id;?>" style="color:yellow; text-decoration:none;"><b >bkash Transfer</b> </a></li>
        </div>
    </div>

Content area

<table width="600" style="text-align:center">

    <h2 style="font-size:30px;"><b>Edit Profile</b></h2>

    <form action="" method="post" enctype="multipart/form-data">

    <tr>
    <td align="right">Name :</td>
        <td align="left"><input type="text" name="name" value="<?php echo $c_name; ?>"/></td>
</tr>



<tr>
    <td align="right">Mobile :</td>
        <td align="left"><input type="text" name="mobile" value="<?php echo $c_mobile; ?>"/></td>
</tr>

<tr>
    <td align="right">Email :</td>
        <td align="left"><input type="text" name="email" value="<?php echo $c_email; ?>"/></td>
</tr>

<tr>
    <td align="right">Address:</td>
        <td align="left"><input type="text" name="address" value="<?php echo $c_address; ?>" /></td>
</tr>



            <tr >

                <td align="right"><b>Image</b></td>
                <td align="left"><input type="file" name="product_image" onchange="readURL(this)";/>
                                 <img id="preview" src="#" alt="Please Select A Image" width="200px" height="200px"/>
</td>
            </tr>
            <tr>



            <tr align="center">


                <td colspan="8" align="center"><input type="submit" name="update" value="Update Profile" /></td>
            </tr>



</form>
</table>


<form id="Imgfrm">
   <input id="imgfile" type="file" onchange="readURL(this)"; /> 
   <img id="preview" src="#" alt="your image" />
</form>

<script>
$("#imgfile").change(function(){
    if (this.files && this.files[0]) {
        var reader = new FileReader();
        reader.onload = function (e) {
            $('#preview').attr('src', e.target.result);
        }
        reader.readAsDataURL(this.files[0]);
    }
});




                    <h1>Welcome to Iqbal Enterprise</h1>
                </div>

            </div>
            </div>
            <?php

include ('footer.php');
?>

        </div>

main Container end

</body>
</html>

<?php
    if (isset($_POST['update'])){
        //gatting the data from the fields
        $product_title = $_POST['product_title'];
        $product_cat = $_POST['mobile'];
        $product_brand = $_POST['address'];
        $product_price = $_POST['product_price'];
        $product_desc = $_POST['product_desc'];
        $product_keyword = $_POST['product_keyword'];

        //gatting the image from the fields
        $product_image = $_FILES ['product_image']['name'];
        echo $product_image_tmp = $_FILES ['product_image']['tmp_name'];

        move_uploaded_file ($product_image_tmp, "customer_image/$product_image");

        $update_product = "UPDATE customer_register SET customer_image='$product_image', mobile='$product_cat', address='$product_brand' WHERE id='$c_id'";


        $update_pro = mysqli_query ($con, $update_product);

        if ($update_pro){
            echo "<script type='text/javascript'>alert('Your Profile Has been Successfully Update')</script>";
            echo "<script type='text/javascript'>window.open('edit_profile.php?edit=$c_id','_self')</script>";
        }
        else {
            echo "<script type='text/javascript'>alert('Sorry Your Profile Has been not Update')</script>";
        }
    }

?>


<?php }else{ echo "<SCRIPT LANGUAGE=\"JavaScript\">window.location=\"index.php?status=Invalid user or password\";</script>)";}?>

    }

722 questions

656 answers

179 comments

4,747 users

Welcome to IDB Scholars Forum, where you can ask questions and receive answers from other members of the community. It's 100% free.
আইডিবি স্কলারস ফোরামে আপনাকে স্বাগত - প্রোগ্রামিং, ডিজাইন, ডেভেলপমেন্ট, ব্লগিং, ইন্টারনেটসহ তথ্য প্রযুক্তির যাবতীয় বিষয় নিয়ে আলোচনার একটি মুক্ত মঞ্চ হলো এই ফোরাম । এখানে আইসিটি বিষয়ক আপনার প্রশ্ন, উত্তর এবং অভিজ্ঞতা শেয়ার করুন, আলোচনা করুন এবং সমাধান নিন। দেশের তরুণ প্রজন্মকে আইসিটিতে আগ্রহী করাই আমাদের মূল লক্ষ্য।
** ইংলিশ বা বাংলা যে কোনো ভাষায় আপনি এই ফোরামে আলোচনা করতে পারবেন। তবে বাংলাকে ইংরেজি অক্ষরে লিখবেন না।
  1. tulbadex

    110 points

    0 answers

  2. JettaQoa3381

    100 points

    0 answers

  3. clutch7conga

    100 points

    0 answers

  4. WhitneyMauer

    100 points

    0 answers

  5. pajamazipper55

    100 points

    0 answers

...