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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:10:23+00:00 2026-06-11T02:10:23+00:00

Hello for some reason I can’t get my program to see if my file

  • 0

Hello for some reason I can’t get my program to see if my file is empty or not if something is selected it should not go through but it is. Here is the code

if (empty($_FILES['file'] ) )
    {
        echo "testing";
        $seterror =1;
        returnBack();

    } 
  • 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-11T02:10:25+00:00Added an answer on June 11, 2026 at 2:10 am

    The language construct empty() and arrays in PHP do not mix well. In addition, if you have a <input type='file' name='file' /> in your form, you will get a $_FILES[] array. You should be doing if( !array_key_exists('file', $_FILES) ) { // no file uploaded } to start with.

    In fact, you should be doing several checks:

    • If the file element is populated in $_FILES
    • If there is no error (that is, $_FILES['file']['error'] == 0)
    • If there is a filename for the uploaded file’s temporary location
    • If PHP believes it is an uploaded file and/or it can move it

    Only of all of those are true will you have a file to process. Otherwise you don’t.

    I’ve found following these steps religiously on a file upload handler to be thoroughly reliable.

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

Sidebar

Related Questions

For some reason my shell script mode hooks do not get executed. Example in
Hello I have the code below that for some reason is not working: I
For some reason I can't get Basic Authentication to work using PHP on my
I am new to Codeigniter but for some reason I can't get it working.
For some reason, I can't get filehandles working with Expect.pm's log_file method. I originally
Hello I was reading through some other posts about my issue on SO that
Possible Duplicate: How can I get the content of the file specified as the
Hello For some reason echoing site_url gives me http://mydomain/ blog instead of http://mydomain .
Not as in can't find the answer on stackoverflow, but as in can't see
NSString *string = @HELLO; For some reason, XCode won't auto-complete methods like remove characters

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.