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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:16:42+00:00 2026-06-13T23:16:42+00:00

This is my image uploading page. what i want is lil bit edition. I

  • 0

This is my image uploading page. what i want is lil bit edition. I want image name look like (folder) image/userid_time.jpg

so i want to upload image to image folder,

and i want all image have new name or we can say unique name.

any adition in this please.

<?php // upload2.php
echo <<<_END
<html><head><title>PHP Form Upload</title></head><body>
<form method='post' action='upload2.php' enctype='multipart/form-data'>
Select a JPG, GIF, PNG or TIF File:
<input type='file' name='filename' size='10' />
<input type='submit' value='Upload' /></form>
_END;
if ($_FILES) {
    $name = $_FILES['filename']['name'];
    switch ($_FILES['filename']['type']) {
        case 'image/jpeg':
            $ext = 'jpg';
            break;
        case 'image/gif':
            $ext = 'gif';
            break;
        case 'image/png':
            $ext = 'png';
            break;
        case 'image/tiff':
            $ext = 'tif';
            break;
        default:
            $ext = '';
            break;
    }
    if ($ext) {
        $n = "image.$ext";
        move_uploaded_file($_FILES['filename']['tmp_name'], $n);
        echo "Uploaded image '$name' as '$n':<br />";
        echo "<img src='$n' />";
    } else
        echo "'$name' is not an accepted image file";
} else
    echo "No image has been uploaded";
echo "</body></html>";
?>

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-06-13T23:16:42+00:00Added an answer on June 13, 2026 at 11:16 pm

    Assuming you can get the user id into a variable called $userId, you can change the $n variable as was previously suggested.

    $timestamp = time();
    $n = "image/$userId_$timestamp.$ext";
    

    When you execute the move_uploaded_file() method, the file will be moved into the image directory relative to the location of your upload script. You might want to make sure that the image folder already exists, and is writable.

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

Sidebar

Related Questions

The upload script in this page is currently uploading the images to the same
I want to get this image uploading script right, but for whatever reason it
I am uploading image using filedrop.js. Code in application.js file looks like this:- $(.droparea).each(function(event){
Please look at this image here is 3 tables , and out i want
I want to upload image with the help of ajax or jQuery without page
See this Image below http://i46.tinypic.com/2pt6jkn.jpg This is report in SSRS as shown when it
Suppose I have this image: <img src=images/01.jpg border=0 rel=shadow /> Then with jQuery, I
I've got this image: I want to code this image (just the bar, not
I have this image: What I want to do is to add a UITapGestureRecognizer
how can i make an uploading image page via razor syntax (CSHTML) to simply

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.