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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:14:00+00:00 2026-05-25T02:14:00+00:00

I am using this function to upload my files: if ((($_FILES[Artwork][type] == image/gif) ||

  • 0

I am using this function to upload my files:

if ((($_FILES["Artwork"]["type"] == "image/gif")
|| ($_FILES["Artwork"]["type"] == "image/jpeg")
|| ($_FILES["Artwork"]["type"] == "image/jpg")
|| ($_FILES["Artwork"]["type"] == "image/pjpeg"))
&& ($_FILES["Artwork"]["size"] < 20000000))
  {
  if ($_FILES["Artwork"]["error"] > 0)
    {
    //echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />";
    }else{
      $imageName = $_FILES['Artwork']['name'];
      move_uploaded_file($_FILES["Artwork"]["tmp_name"],
      $path_image . $imageName);
      }
    }else{
    //echo "invalid file";
    }

How do I change $imageName = $_FILES['Artwork']['name']; with a custom name, but mantaining the file extension in the name, so for example: myCustomName.jpg?

Thanks!

  • 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-25T02:14:01+00:00Added an answer on May 25, 2026 at 2:14 am

    The only line you need modified in your code is:

    $imageName = 'CustomName.' . pathinfo($_FILES['Artwork']['name'],PATHINFO_EXTENSION);
    

    Where ‘CustomName.’ is the new name you want for the image.
    pathinfo if the PHP function to handle the operations with paths and files names.

    You whole code would be:

    if ((($_FILES["Artwork"]["type"] == "image/gif")
    || ($_FILES["Artwork"]["type"] == "image/jpeg")
    || ($_FILES["Artwork"]["type"] == "image/jpg")
    || ($_FILES["Artwork"]["type"] == "image/pjpeg"))
    && ($_FILES["Artwork"]["size"] < 20000000))
      {
      if ($_FILES["Artwork"]["error"] > 0)
        {
        //echo "Return Code: " . $_FILES["Artwork"]["error"] . "<br />";
        }else{
          $imageName = 'CustomName.' . pathinfo($_FILES['Artwork']['name'],PATHINFO_EXTENSION);
          move_uploaded_file($_FILES["Artwork"]["tmp_name"],
          $path_image . $imageName);
          }
        }else{
        //echo "invalid file";
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've made an image upload script using the move_uploaded_file function. This function seems to
i am making an upload with Ajaxupload plugin and i am using this function
I'm using this function to extract files from .zip archive and store it on
I'm using the following CodeIgniter function to upload files which works fine: function uploadFiles(){
hii i am using ajax file upload in this code <script type=text/javascript src=fileuploader.js></script> <script
I'm following this tutorial: http://vimeo.com/17442755 . It teaches you how to upload files using
I'm using a single image upload/crop/resize script for files up to 10MB. When testing,
I am using the Uploadify Plugin to Upload files. although this might be a
I've been using this function but I'd like to know what's the most efficient
I am using this function to close existing form and open a new form.

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.