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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T20:59:15+00:00 2026-05-23T20:59:15+00:00

For some reason when trying to upload a zip file this function always returns

  • 0

For some reason when trying to upload a zip file this function always returns false. The directories are all set to 0777 for permissions. I’m stumped as to what could be wrong.

function uploadProof ( $file, $email )
{
    // Check or create for existing directory
    if ( !is_dir('client_files/'.$email))
    {
        mkdir('client_files/'.$email);
        if ( !is_dir('client_files/'.$email.'/proof/'))
        {
            mkdir('client_files/'.$email.'/proof/');
        }
    }
    // Target path
    $target_path = 'client_files/'.$email.'/proof/';

    // File information
    $filename = date('Y_M_D').$email.'.zip';
    $tmp_name = $file['tmp_name'];
    $filesize = $file['size'];

    // Blacklist and Max file info
    $max_allowed = (1024 * 1024) * 99; // 99 MB
    $blacklist = array(
        '.pl', '.php', '.phtml', '.php3', '.php4', '.php5'
    );

    // Check filename
    foreach ( $blacklist as $nope)
    {
        if ( preg_match("/$nope\$/i", $filename))
        {
            die("As previously stated, we do not allow php files of any type\n
                to be uploaded to our server.\n\n");
        }
    }

    // Check filesize
    if ( $filesize > $max_allowed)
    {
        die("File is too big, file needs to be less than <em>20MB</em> in size.");
    }
    else
    {
        $target = $target_path.$filename;

        if (move_uploaded_file($tmp_name, $target))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}
  • 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-23T20:59:15+00:00Added an answer on May 23, 2026 at 8:59 pm

    You do need to check if the upload actually succeeded, before going on to do what might be a totally useless set of operations:

    function uploadProof ( $file, $email ) {
       if ($file['error'] !== UPLOAD_ERR_OK) {
           die("Upload failed with error code " . $file['error']);
       }
       ...
    }
    

    The error codes are defined here.

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

Sidebar

Related Questions

For some reason, when I'm trying to compile my .cs file into a .dll
I was trying to set the text given below but for some reason JEditorPane
I am trying to print into a file in C++ and for some reason
i am trying to get jquery to hide this div and for some reason
hi im trying to using flashVars however for some reason there not getting sent
I am trying something very simple, but for some reason it does not work.
I'm trying to do a very simple INSERT using VB.NET. For some reason I'm
For some reason I never see this done. Is there a reason why not?
I'm trying to get a file upload progress bar working in a rails 3
I'm trying to upload an ics file to my site. It was exported from

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.