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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:05:09+00:00 2026-05-29T09:05:09+00:00

I have an user registration form and uploading image with other form elements is

  • 0

I have an user registration form and uploading image with other form elements is optional there. So sometimes users may not upload image along with other data.

Now the problem is even though the user has not uploaded image, the following code always echos that the file was uploaded

Could you please kindly tell me how to check if the image was submitted by the user and make it echo/display “not uploaded” if not uploaded ?

Thanks in Advance 🙂

In my Controller File

extract($_POST); // <<This is to retrieve all form data at once

if(isset($_FILES['userfile'])){
    echo"file uploaded";
} else{
    echo "Not Uploaded";
}

This is in my View File

<input type="file" class="" name="userfile" size="20" />
  • 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-29T09:05:10+00:00Added an answer on May 29, 2026 at 9:05 am

    Per PHP documentation:

    If no file is selected for upload in your form, PHP will return $_FILES[‘userfile’][‘size’] as 0, and $_FILES[‘userfile’][‘tmp_name’] as none.

    source: http://www.php.net/manual/en/features.file-upload.post-method.php

    So your conditional can change to:

    if(isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0){
         echo"file uploaded";
    } else echo "Not Uploaded" ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have working user registration form. It consist of Zend Form Elements. Now I
I have a user registration form in PHP .I put captcha image check in
Let's say I have an user registration form. In this form, I have the
I have a product registration form that allows the user to add additional product
In my web application i have registration form, when user register i want to
I have a user registration form. I am doing server side validation on the
I have a user registration form that has a password and confirm password field.
I have created a user registration form in CakePHP. My intention is if user
I have a custom user registration form at: somepath/register using hook form alter. I
I have simple user registration form. In which i am puting city as 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.