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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:26:55+00:00 2026-06-06T06:26:55+00:00

i am developing register form using php where i need to upload the file

  • 0

i am developing register form using php where i need to upload the file its not uploading

$firstname=$_REQUEST['firstname'];
$lastname=$_REQUEST['lastname'];
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
$email=$_REQUEST['email'];
$Image=basename($_FILES['file']['name']);
$Image=str_replace(' ','|',$Image);

if($firstname && $lastname && $username && $email)
{
  require 'dbconnect.php';
  $query="select * from members where email='$email'";
  $result=mysql_query($query);
  $exists=mysql_num_rows($result);
  if($exists>0)
  {
    $message=array("message"=>"email already existed");
    echo json_encode($message);
  }
  else
  {
    if($Image)
    { 
      $Image=date("YmdHis").".jpg";    
      $target_path="userimages/".$Image;
      move_uploaded_file($_FILES["file"]["tmp_name"],$target_path);
      $query="INSERT INTO `members` 
        (`username`, `firstname`, `lastname`, `email`, `password`, `image`)  VALUES 
        ('$username', '$firstname', '$lastname', '$email', '$password',  '$Image')";
    }
    else
    {
      $query="INSERT INTO `members` (`username`, `firstname`, `lastname`, `email`, `password`)  VALUES 
       ('$username', '$firstname', '$lastname', '$email', '$password')";
    }
    $result=mysql_query($query);
  }
}

html code is

<html>
<form action="register.php" method="post" enctype="multipart/form-data">
<div>firstname<input type="text" name="firstname"></div>
<div>lastname<input type="text" name="lastname"></div>
<div>username<input type="text" name="username"></div>
<div>password<input type="text" name="password"></div>
<div>email<input type="text" name="email"></div>
<div>image<input type="file" name="file"></div>
<div><input type="submit" name="submit"></div>
</form>
</html>

in this i upload image but its not uploaded to server and also to database in this else condition is exicuted

please 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-06T06:26:57+00:00Added an answer on June 6, 2026 at 6:26 am

    Check the permissions on the folder you are trying to write to – if the image is not being uploaded and the move_uploaded_file fails, then the row won’t be inserted into the database at all.

    For comparison, here’s some code from an app I use to upload a file to the server:

    if ((($_FILES["avatar"]["type"] == "image/gif")
        || ($_FILES["avatar"]["type"] == "image/jpeg")
        || ($_FILES["avatar"]["type"] == "image/pjpeg")
        || ($_FILES["avatar"]["type"] == "image/png"))
        && ($_FILES["avatar"]["size"] < 200000))
    {
        if ($_FILES["avatar"]["error"] > 0)
        {
            $error =  "Return Code: " . $_FILES["avatar"]["error"] . "<br />";
        }
        else
        {
            $fname = time() . '-' . $formData['username'] .$_FILES["avatar"]["name"];
            $fname = str_replace(" ", "_", $fname);
            if (file_exists("/myserverdir/images/avatars/" . $fname))
            {
                $fname = time() . '-' . $formData['username'] .$_FILES["avatar"]["name"];
                $fname = str_replace(" ", "_", $fname);
            }
            move_uploaded_file($_FILES["avatar"]["tmp_name"], "/myserverdir/images/avatars/" . $fname);
        }
    }
    else if (!file_exists($_FILES['avatar']['tmp_name']) || !is_uploaded_file($_FILES['avatar']['tmp_name']))
    {
        $fname = 'default_avatar.jpg';
    }
    else
    {
        $error = "Invalid file";
    }
    

    My form looks something like:

    <form method="post" action="myaction.php" enctype="multipart/form-data">
        <input type="file" name="avatar" />
        <input type="text" name="username" />
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a application using Java RMI which enable clients to register topics they
Simple question, I'm developing an application that will register its own URL Scheme. I
If I'm developing a service, do I need to unregister and register the service
I am developing iOS app using phonegap. Users first have to register or log
I am developing an iPhone application for car dealers who would register with my
I am developing a business portal for a company, where users must register before
Developing a project of mine I realize I have a need for some level
Developing a C# .NET 2.0 WinForm Application. Need the application to close and restart
While developing an application using gwt in ecliplse crashed. Now the server is running
Currently I'm developing a registration form for new user in Android (native app.) and

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.