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

  • Home
  • SEARCH
  • 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 7852057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:19:43+00:00 2026-06-02T19:19:43+00:00

This is a script I got from devshed. It works great in Opera and

  • 0

This is a script I got from devshed. It works great in Opera and others (not in IE). My question is: how does this script works without $_FILES['userfile']['name'] & $_FILES['userfile']['tmp_name']?

<?php
    class FileUploader
    {
    private $uploadFile;
    private $name;
    private $tmp_name;
    private $type;
    private $size;
    private $error;
    private $allowedTypes=array
    ('image/jpeg','image/gif','image/png','text/plain','application/ms-word');

    public function __construct($uploadDir="./uploadfl/")
    {
    if(!is_dir($uploadDir)){
    throw new Exception('Invalid upload directory.');
    }

    if(!count($_FILES))
    {
    throw new Exception('Invalid number of file upload parameters.');
    }

    foreach($_FILES['userfile'] as $key=>$value)
    {
    $this->{$key}=$value;
    }

    if(!in_array($this->type,$this->allowedTypes))
    {
    throw new Exception('Invalid MIME type of target file.');
    }

    $this->uploadFile=$uploadDir.basename($this->name); 

    }
    // upload target file to specified location

    public function upload(){
    if(move_uploaded_file($this->tmp_name,$this->uploadFile)){
    return true;
    }


    }
    }
    ?>

    <?php
      if($_POST['send']){
    //require_once 'fileuploader.php';
    $fileUploader=new FileUploader();
    if($fileUploader->upload()){
    echo 'Target file uploaded successfully!';
    }
    }
?> 
  • 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-02T19:19:45+00:00Added an answer on June 2, 2026 at 7:19 pm

    To answer your question (How this script works without $_FILEs[‘userfile’][‘name’] & $_FILEs[‘userfile’][‘tmp_name’]):
    It does work without it because the array keys are assigned as properties here:

    $this->{$key}=$value;
    

    So instead of $_FILES[‘userfile’][‘tmp_name’] it can now be referred to as

    $this->tmp_name
    

    You’ve already got a reply as to why it might not work in all browsers.

    Hope that helps,
    Stefan

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

Sidebar

Related Questions

This is the calendar script I got from an online tutorial. It works fine
I got this script which works perfect when i am not using jquery's alert
I've got this script $(date +%Y-%m-01) -$i months +%Y-%m)-01 that works great for getting
I've got a bash script that reads input from a file like this: while
I got this javascript code from off the internet. It's a script that changes
How do I execute an output piped from a bash script? I got this
i got this script from this tutorial . I tried to convert it from
I was trying this script from a pdf file.I got stuck where the target
Hi All First of all I don't know Javascript, I got this script from
This is script from an audio player. I got from the Jquery cookbook that

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.