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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:05:20+00:00 2026-05-13T08:05:20+00:00

I use Windows and I display a file extention. When I upload an image

  • 0

I use Windows and I display a file extention.

When I upload an image file with PHP, a image name of image1_big.jpg becomes image1_big.jpg.jpg.

And image2.gif becomes image2.gif.gif.

I don’t want to turn off file extension.

How can I avoid this problem?

function addProduct(){
    $data = array( 
        'name' => db_clean($_POST['name']),
        'shortdesc' => db_clean($_POST['shortdesc']),
        'longdesc' => db_clean($_POST['longdesc'],5000),
        'status' => db_clean($_POST['status'],8),
        'class' => db_clean($_POST['class'],30),
        'grouping' => db_clean($_POST['grouping'],16),
        'category_id' => id_clean($_POST['category_id']),
        'featured' => db_clean($_POST['featured'],5),
        'price' => db_clean($_POST['price'],16)

    );

    if ($_FILES){
        $config['upload_path'] = './images/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '200';
        $config['remove_spaces'] = true;
        $config['overwrite'] = false;
        $config['max_width']  = '0';
        $config['max_height']  = '0';
        $this->load->library('upload', $config);    
        if (strlen($_FILES['image']['name'])){
            if(!$this->upload->do_upload('image')){
                $this->upload->display_errors();
                exit();
            }
            $image = $this->upload->data();
            if ($image['file_name']){
                $data['image'] = "images/".$image['file_name'];
            }
        }
        if (strlen($_FILES['thumbnail']['name'])){
            if(!$this->upload->do_upload('thumbnail')){
                $this->upload->display_errors();
                exit();
            }
            $thumb = $this->upload->data();
            if ($thumb['file_name']){
                $data['thumbnail'] = "images/".$thumb['file_name'];
            }
        }
    }
    $this->db->insert('omc_products', $data);   

    $new_product_id = $this->db->insert_id();
...
...
  • 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-13T08:05:21+00:00Added an answer on May 13, 2026 at 8:05 am

    if you feel you need to, you can just strip the file extention. However, i would go with BalusC’s comment that it is not the correct behavior for PHP in general:

    $filename = substr($filename_passed_to_upload, 0, (strlen($filename_passed_to_upload) - 4));
    

    or, more rigourously:

    $temp = explode(".", $filename_passed_to_upload);
    $new_filename = $temp[0]; 
    // be careful, this fails when the name has a '.' in it other than for the extention
    // you'll probably want to do something with a loop with $temp
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i use a treeView and a listView to display file and folders like Windows
I use data binding to display values in text boxes in a C# Windows
We use Windows for our development systems. I am installing PHP, Apache, MySQL manually.
I'm using System.Windows.Forms.Timer to display a transfer file update progress(timeleft, speed ..etc) and I
Practically, I don't understand the use of the sBIT chunk in an PNG file.
I am trying to display an image file in web browser via the Apache
I will use the following javascript to display a Google Map Window in a
How do I use Windows Authentication to connect to an Oracle database? Currently, I
Can you use windows hooks or other methods to do code injection with c#?
How do I use Windows Vista's FOLDERID API in order to retrieve filepaths for

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.