hello i have the following code to change the image name of upload picture

$TARGET_PATH="pics/";
$TARGET_PATH =$TARGET_PATH . basename( $_FILES['photo']).'.jpg';
while (file_exists($TARGET_PATH))
    {
$TARGET_PATH =$TARGET_PATH . basename( $_FILES['photo']) . uniqid() . '.jpg';
}

This change the name of image or file but dont sho the extention it just show dot(.) at end of name i.e 1=>file.<br/>2=>filefile9534803.

If you have an input element of type="file" whose name="photo" then you should be using $_FILES['photo']['name'] since $_FILES['photo'] would actually be an array.

$TARGET_PATH="pics/";
$TARGET_PATH =$TARGET_PATH . $_FILES['photo']['name'] . '.jpg';
while (file_exists($TARGET_PATH))
    {
$TARGET_PATH =$TARGET_PATH .  $_FILES['photo']['name']. uniqid() . '.jpg';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.