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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:05:02+00:00 2026-06-12T17:05:02+00:00

I am uploading an image to a folder name upload. Then I am changing

  • 0

I am uploading an image to a folder name “upload”. Then I am changing the name and extension of the image. I am getting the current time and date with default time zone
now I am trying to set the image extension to “jpeg” after the getted date and time I was
tried but is not given result I put my code here

I suppose when I upload image at that time my file name is “NEWYORK.JPG” But after
upload the image I want to change the file name is “9/10/2012/05:31:15.jpeg” from
get the current time and date set default time zone.

date_default_timezone_set('Asia/Kolkata');
$imagename = date('d/m/Y-h:i:s', time());
$imagename=basename($imagename,".jpg");
echo $filename = $imagename;
$upload   = $_FILES['ctgimage'];
$target_path = "upload/";

 echo $target_path .= $filename . "." . path_info($upload["name"], PATHINFO_EXTENSION);
  if(move_uploaded_file($upload["tmp_name"],$target_path))
  {
          echo "uploaded successfully";           $cname=$_POST['ctgname'];
          mysql_query("insert into category(ctg_name,ctgimage) 
               values('$cname','$target_path')");

  }
  • 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-12T17:05:03+00:00Added an answer on June 12, 2026 at 5:05 pm

    Some Errors

    • It should be pathinfo not path_info
    • Use a valid File name like d-m-Y for folder h.i.s for file
    • Too many Duplication
    • Avoid SQL Injection by escaping

    Example :

    date_default_timezone_set('Asia/Kolkata');
    
    $target_path = "upload/";
    $imageDir = date('d-m-Y', time());
    $imageName = date('h.i.s', time());
    
    $upload = $_FILES['ctgimage'];
    $uploadExtention = pathinfo($upload["name"], PATHINFO_EXTENSION);
    
    if (! is_dir($target_path . "/" . $imageDir)) {
        mkdir($target_path . "/" . $imageDir);
    }
    
    $target_path = "$target_path/$imageDir/$imageName.$uploadExtention";
    $cname = mysql_real_escape_string($_POST['ctgname']);
    
    if (move_uploaded_file($upload["tmp_name"], $target_path)) {
        echo "uploaded successfully";
    
        mysql_query("insert into category(ctg_name,ctgimage)
        values('$cname','$target_path')");
    }
    

    PHP DOC on mysql_*****

    Use of this extension is discouraged. Instead, the MySQLi or PDO_MySQL extension should be used. See also MySQL: choosing an API guide and related FAQ for more information. Alternatives to this function include:

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

Sidebar

Related Questions

when I am uploading an image into serverside, and saved in a specific folder.
Instead of uploading image one by one, how do i achieve to upload all
So i'm uploading any image file via my great upload form and it uploads
I'm using this php code for an image upload. But I keep getting an
I have an upload script for uploading an image. my directory looks like this:
I am uploading image using filedrop.js. Code in application.js file looks like this:- $(.droparea).each(function(event){
I am uploading image to server using base64 its working fine if image is
I am uploading an image. When I run application from eclipse on my device
My user is uploading an image of any size XX x YY. I want
I am uploading in image via a form and I want to, in addition

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.