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 1016035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:29:26+00:00 2026-05-16T10:29:26+00:00

I am having problem uplaoding file, here are my codes: Any help? Thanks! test.html

  • 0

I am having problem uplaoding file,
here are my codes:
Any help? Thanks!

test.html

function insertPhoto()
{
    var description = document.getElementById('description').value;
    var image = document.getElementById('photo').value;
        var url = "ajax_insert.php?action=add&image="+image+"&description="+description;
    var ajaxRequest = ajax_obj();

            ajaxRequest.onreadystatechange = function() {
                        if(ajaxRequest.readyState == 4){

                document.getElementById("msgbox").innerHTML=ajaxRequest.responseText;

            }             
        }

        ajaxRequest.open("GET", url, true);
            ajaxRequest.send(null);

        return false;
}

<div align="center">
  <div class="top" >
    <div>
       Decription <input name="description" type="text" id="description" value="" maxlength="20" />
    </div>
    <div style="margin-top:5px" >
 Image
        <input name="photo" type="file" id="photo" value="" maxlength="20" />
    </div>
    <div class="buttondiv">
        <input name="button" type="button" value="Upload" onclick="return insertPhoto()" style="margin-left:-10px; height:23px"  /> 
        <span id="msgbox" style="display:none"></span>
    </div>
  </div>
</div>

ajax_insert.php

<?php
    mysql_connect('localhost','root','');
    mysql_select_db('priceless');
    define('DIR_IMAGE','images/');

    $image = $_GET['image'];
    $description = $_GET['description'];
    $dbtable = 'photos';
    $action = $_GET['action'];

    if($action == 'add'){
           $photo = '';
                if ($_FILES[$image]['name']) {
                    $aray = explode(".",$_FILES[$image]['name']);
                    $ext = $aray[count($aray)-1];
                    $photo = date('Ymdhis').'.'.$ext;
                    move_uploaded_file($_FILES[$image]['tmp_name'],DIR_IMAGE.$photo);
                } 

               $data = array(
              'image'=> $photo,
              'description'=> $description
               );
                $values = array();
                foreach($data as $show){
                    $values[] = $show;
                }        
              $query = "INSERT INTO ".$dbtable." (`".implode("`,`",array_keys($data))."`) values ('".implode("','",array_values($values))."')";
              if ($result= mysql_query($query) or die(mysql_error())) {        
                 echo "You have Sucessfully Upload Photo!";              
            }
    }
?>
  • 1 1 Answer
  • 4 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-16T10:29:26+00:00Added an answer on May 16, 2026 at 10:29 am

    Personally I use this Ajax upload http://valums.com/ajax-upload/ and I’m satisfied with results.

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

Sidebar

Related Questions

I'm having a problem here trying to upload a file with powershell. What I'm
Having problem reading bytearray of custom objects. Any help is appreciated public class CustomObject
I've been having a problem uploading a CSV file to Heroku and processing it.
Can anyone help with a small problem I am having, I have WCF Rest
I am having a problem here in itunes connect. My bundle ID is myapp
Having problem understanding Delegate error. Error says expression expected, How do I fix? Thanks
I'm using Aptana Studio 3 and I've been having no problem in accessing any
I'm having problems uploading and even viewing files in the File section of MODX
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
Im having problem in my UIscrollView ,this is what I have done: Whenever a

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.