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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:42:19+00:00 2026-06-06T14:42:19+00:00

Language: PHP / Using Class Upload by Colin Verot About: Multiple Uploading The code

  • 0

Language: PHP / Using Class Upload by Colin Verot
About: Multiple Uploading

The code below already uploads the files fine, it works…
PROBLEM: I am having trouble figuring out how to get the filename extension.
(In a comment below, I have specified where my problem area is…)

// CONNECTION TO DATABASE HERE...

// INCLUDE UPLOAD CLASS LIBRARY
include (dirname(__FILE__).'/lib/class.upload.php');

$files = array();
foreach ($_FILES['fileupload'] as $k => $l)
{
    foreach ($l as $i => $v)
    {
        if (!array_key_exists($i, $files))
        $files[$i] = array();
        $files[$i][$k] = $v;
        $imagename = $_FILES['fileupload']['name'];
    }
}

foreach ($files as $file) {

            // THIS IS MY PROBLEM AREA, GETTING FILE EXTENSION
            $ext=strchr($imagename,".");

            $generate_name = rand(100,99999); 
            $generate_name_extra = rand(200,9999);
            $filenamex = "PHOTO_".$generate_name.$generate_name_extra."_".time();
            $filenamex_thumb = $filenamex."_thumb";

            // COMPLETE FILENAME WITH EXTENSION
            $filename = $filenamex.strtolower($ext);
            $handle = new upload($file);
            if ($handle->uploaded) {
            ///// 1 ////////////////////////////////////////////////////////////////////
            $handle->file_new_name_body   = $filenamex_thumb;
            $handle->image_resize         = true;
            $handle->image_x              = '300';
            $handle->image_ratio_y        = true;
            $handle->jpeg_quality = '100';

            // ABSOLUTE PATH BELOW
            $handle->process($absoRoot.'covers/thumbs/');

            if ($handle->processed) {

            // SUCCESSFUL RESPONSE

        }
      else
        {

         // FAILED RESPONSE

        }     
    }
}

And the webform is:

<form method="post" action="upload.php" enctype="multipart/form-data">
<input name="fileupload[]" id="fileupload" type="file" multiple>

I really pretty much need the file extensions to serve the files correctly online, but I can’t spot where to find it. I have tried using: $files[$i][$k] instead of $imagename in my specified problem area above, as well as $file and other possible solutions, but I can’t spot which one’s going to give me the filename with extension.

Hopefully someone could point it out. Thank you for your time and assistance!

  • 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-06T14:42:20+00:00Added an answer on June 6, 2026 at 2:42 pm
    $ext=array_pop(explode('.', $imagename));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm makin' a scripting language interpreter using PHP. I have this code in that
The following is a great tutorial about using the Language Class. But I think
Im using class.twitter.php ( http://emmense.com/php-twitter/documentation/v11-methods-available/ ) Im using this code: $summize = new summize;
I am using this code to encryp/decrypt strings between c# and php: class encryption
I've started to learn OO programming, but using the PHP language with the help
Programming Language I am using : PHP I have 30 results from database, which
I use the PHP language for file upload and want to know that the
I'm doing a project for a college class I'm taking. I'm using PHP to
I'm trying to build site using OOP in PHP. Everyone is talking about Singleton,
hii i am using ajax file upload in this code <script type=text/javascript src=fileuploader.js></script> <script

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.