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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:49:40+00:00 2026-05-14T16:49:40+00:00

I have this code I been working on but I’m having a hard time

  • 0

I have this code I been working on but I’m having a hard time for it to work. I did one but it only works in php 5.3 and I realized my host only supports php 5.0! do I was trying to see if I could get it to work on my sever correctly, I’m just lost and tired lol

Ol, sorry stackoverflow is a new thing for me. Not sure how to think of it. As a forum or a place to post a question… hmmm, I’m sorry for being rude with my method of asking.

I was wondering i you could give me some guidance on how to properly insert directory structures with how i written this code. I wasn’t sure how to tell the PHP where to upload my files and whatnot, I got some help from a friend who helped me sort out some of my bugs, but I’m still lost with dealing with the mkdir and link, unlink functions. Is this how I am suppose to refer to my diretories?

I know php 5.3 uses the _ DIR _ and php 5.0 use dirname(_ _ FILE_ _), I have tried both and I get the same errors. My files are set to 0777 for testing purposes. What could be the problem with it now wanting to write and move my uploaded file?

    } elseif ( (file_exists("\\uploads\\{$username}\\images\\banner\\{$filename}")) || (file_exists("\\uploads\\{$username}\\images\\banner\\thumbs\\{$filename}")) ) {

        $errors['img_fileexists'] = true;
    }

    if (! empty($errors)) { 
        unlink($_FILES[IMG_FIELD_NAME]['tmp_name']); //cleanup: delete temp file
    }

    // Create thumbnail
    if (empty($errors)) {

        // Make directory if it doesn't exist
        if (!is_dir("\\uploads\\{$username}\\images\\banner\\thumbs\\")) {

            // Take directory and break it down into folders
            $dir = "uploads\\{$username}\\images\\banner\\thumbs";
            $folders = explode("\\", $dir);

            // Create directory, adding folders as necessary as we go (ignore mkdir() errors, we'll check existance of full dir in a sec)
            $dirTmp = '';
            foreach ($folders as $fldr) {
                if ($dirTmp != '') { $dirTmp .= "\\"; }
                $dirTmp .= $fldr;
                mkdir("\\".$dirTmp); //ignoring errors deliberately!
            }

            // Check again whether it exists
            if (!is_dir("\\uploads\\$username\\images\\banner\\thumbs\\")) {
                $errors['move_source'] = true;
                unlink($_FILES[IMG_FIELD_NAME]['tmp_name']); //cleanup: delete temp file
            }
        }

        if (empty($errors)) {

            // Move uploaded file to final destination
            if (! move_uploaded_file($_FILES[IMG_FIELD_NAME]['tmp_name'], "/uploads/$username/images/banner/$filename")) {
                $errors['move_source'] = true;
                unlink($_FILES[IMG_FIELD_NAME]['tmp_name']); //cleanup: delete temp file

            } else {

                // Create thumbnail in new dir
                if (! make_thumb("/uploads/$username/images/banner/$filename", "/uploads/$username/images/banner/thumbs/$filename")) {
                    $errors['thumb'] = true;
                    unlink("/uploads/$username/images/banner/$filename"); //cleanup: delete source file
                }
            }
        }
    }

    // Record in database
    if (empty($errors)) {

        // Find existing record and delete existing images
        $sql = "SELECT `bannerORIGINAL`, `bannerTHUMB` FROM `agent_settings` WHERE (`agent_id`={$user_id}) LIMIT 1";
        $result = mysql_query($sql);
        if (!$result) {
            unlink("/uploads/$username/images/banner/$filename"); //cleanup: delete source file
            unlink("/uploads/$username/images/banner/thumbs/$filename"); //cleanup: delete thumbnail file
            die("<div><b>Error: Problem occurred with Database Query!</b><br /><br /><b>File:</b> " . __FILE__ . "<br /><b>Line:</b> " . __LINE__ . "<br /><b>MySQL Error Num:</b> " . mysql_errno() . "<br /><b>MySQL Error:</b> " . mysql_error() . "</div>");
        }
        $numResults = mysql_num_rows($result);
        if ($numResults == 1) {
            $row = mysql_fetch_assoc($result);

            // Delete old files
            unlink("/uploads/$username/images/banner/" . $row['bannerORIGINAL']); //delete OLD source file
            unlink("/uploads/$username/images/banner/thumbs/" . $row['bannerTHUMB']); //delete OLD thumbnail file
        }

        // Update/create record with new images
        if ($numResults == 1) {
            $sql = "INSERT INTO `agent_settings` (`agent_id`, `bannerORIGINAL`, `bannerTHUMB`) VALUES ({$user_id}, '/uploads/$username/images/banner/$filename', '/uploads/$username/images/banner/thumbs/$filename')";
        } else {
            $sql = "UPDATE `agent_settings` SET `bannerORIGINAL`='/uploads/$username/images/banner/$filename', `bannerTHUMB`='/uploads/$username/images/banner/thumbs/$filename' WHERE (`agent_id`={$user_id})";
        }
        $result = mysql_query($sql);
        if (!$result) {
            unlink("/uploads/$username/images/banner/$filename"); //cleanup: delete source file
            unlink("/uploads/$username/images/banner/thumbs/$filename"); //cleanup: delete thumbnail file
            die("<div><b>Error: Problem occurred with Database Query!</b><br /><br /><b>File:</b> " . __FILE__ . "<br /><b>Line:</b> " . __LINE__ . "<br /><b>MySQL Error Num:</b> " . mysql_errno() . "<br /><b>MySQL Error:</b> " . mysql_error() . "</div>");
        }
    }

    // Print success message and how the thumbnail image created
    if (empty($errors)) {
        echo "<p>Thumbnail created Successfully!</p>\n";
        echo "<img src=\"/uploads/$username/images/banner/thumbs/$filename\" alt=\"New image thumbnail\" />\n";
        echo "<br />\n";
    }
}

I get the following errors:

Warning: move_uploaded_file(./uploads/saiyanz2k/images/banner/azumanga-wall.jpg) [function.move-uploaded-file]: failed to open stream: Permission denied in /services7/webpages/util/s/a/saiya.site.aplus.net/helixagent.com/public/upload2.php on line 112
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move ‘/services/webdata/phpupload/phpVoIEQj’ to ‘./uploads/saiyanz2k/images/banner/azumanga-wall.jpg’ in /services7/webpages/util/s/a/saiya.site.aplus.net/helixagent.com/public/upload2.php on line 112

  • 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-14T16:49:40+00:00Added an answer on May 14, 2026 at 4:49 pm

    One way is to check from within your code whether a certain command/function is available for use. You can use the function_exists function for that eg:

    if (function_exists('date_default_timezone_set'))
    {
      date_default_timezone_set("GMT");
    }
    else
    {
      echo 'date_default_timezone_set is not supported....';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 398k
  • Answers 398k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can listen for the Copy command (listening for ctrl-c… May 15, 2026 at 3:31 am
  • Editorial Team
    Editorial Team added an answer This is achieved by returning $this at the end of… May 15, 2026 at 3:31 am
  • Editorial Team
    Editorial Team added an answer WiX v3.5 is currently in beta, set to be released… May 15, 2026 at 3:31 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.