TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,973
  • Latest: NonStop
Stats
  • Total Posts: 196,231
  • Total Topics: 21,353
  • Online today: 606
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 232
  • Total: 232

PHP Help

Started by captjlucpicard, July 24, 2008, 10:10:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

captjlucpicard

I know this might not be the best place to ask, but everyone here seems pretty knowledgeable, so here it goes..

I'm looking to find out how to rename uploaded image files, into "img_1" "img_2" and so on.

Here is my code:

Quote
<?php
$target_path = "uploads/";

if(getimagesize($_FILES['uploadedfile']['tmp_name'])) {




$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "Upload successful. The link to your image is: http://google.com/" .$target_path . "
" ."
". "Signature code: <FONT size=4>Image";
} else{
    echo "There was an error uploading the file, please try again!";
   }

} else {
  die("You may only upload image files!");
}
?>

Currently, when the file is uploaded, it goes the user the link without the filename change. For example: "http://www.google.com/imagecool.jpg" I want this to change to "http://www.google.com/img_1.jpg"

Ken.

captjlucpicard, most of our code specialists are away for the next few days so you may have to wait a bit before you get an answer.
" If everything seems under control, you're not going fast enough." - Mario Andretti
Yesterday When I was Young.

IchBin

I don't think the the move_uploade_file function works like that. You will probably have to provide some sort of input box to supply a new file name, and use the rename() function. Just my $.02 anyway. :)

This website is proudly hosted on Crocweb Cloud Website Hosting.