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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:00:22+00:00 2026-06-08T19:00:22+00:00

I currently have the following: if (in_array($_FILES[‘userfile’][‘type’], $mimeTypes)) { $target_path = ./uploads/{$_SESSION[’email’]}; $target_path =

  • 0

I currently have the following:

    if (in_array($_FILES['userfile']['type'], $mimeTypes))
      {

$target_path = "./uploads/{$_SESSION['email']}";

$target_path = $target_path . basename( $_FILES['userfile']['name']);

if(move_uploaded_file($_FILES['userfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['userfile']['name']).
    " has been uploaded";

} else{
    echo "There was an error uploading the file, please try again!";
}

When someone creates a login, a directory is created for the user using their email, 0666 permission.

Currently, the move_uploaded_file() places the file just oustide of the user’s directory, inside the uploads directory. The error is being thrown. I’ve checked many times that my relative path is correct.

I’m using Ubuntu and the uploaded file has a Lock symbol on it, but lets me drag and drop into the user’s folder.

  • 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-08T19:00:24+00:00Added an answer on June 8, 2026 at 7:00 pm

    Your $target_path appears to be missing a / following the user’s directory, since basename()‘s output won’t include a /.

    // Append trailing slash
    $target_path = "./uploads/{$_SESSION['email']}/";
    $target_path = $target_path . basename( $_FILES['userfile']['name']);
    

    The correct permissions for a directory should be 0755 (you don’t want it world-writable!), as directories should have execute permissions to be traversed by the filesystem. You can make it group-writable (0775) and make sure the upload directories have their group set to the Apache web server user. This would be best done by setting setgid on the uploads/ directory and setting its group to the apache user so use directories created beneath it inherit the correct write permissions without being world-writable.

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

Sidebar

Related Questions

I currently have the following in select expert to select a bunch of fields:
I currently have the following in one solution: Core Project (data access, biz logic,
I currently have the following row in my table: course_data: user_id days <-- This
I currently have the following up in VS 2010 Dim myProcess() As Process =
I currently have the following controller method in a Rails app: def index @entries
I currently have the following models/toy.rb file in my RoR project: class ToysPurchased include
Currently I have to write the following to update an element already contained in
I have the following problem: I have a form in site/banen (currently local running
I currently have the following lines of code in a script: set -A ARRAY
I have the following program that writes a user's input to a file. Currently

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.