Jump to content

slight problem with naming files in php gallery


slaterino

Recommended Posts

Hi,

Hopefully there's a quick answer to this issue. The filenames that I'm currently creating for the album images in my gallery are ending with an extra full stop. For example, the name could X78GUB832..jpg. I'm currently having some problems with my gallery in Firefox and want to rule this out as a problem. Below is my code for the page that this is on. Can anyone tell me why the extra full stop is being produced?

 

/////

 

<?php

require_once '../library/config.php';

require_once '../library/functions.php';

if(isset($_POST['txtName']))

{

$albumName = $_POST['txtName'];

$albumDesc = $_POST['mtxDesc'];

 

$imgName  = $_FILES['fleImage']['name'];

$tmpName  = $_FILES['fleImage']['tmp_name'];

 

$ext = strrchr($imgName, ".");

 

$newName = strtolower(md5(rand() * time()) . ".$ext");

 

    $imgPath = ALBUM_IMG_DIR . $newName;

 

$result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH);

 

if (!$result) {

echo "Error uploading file";

exit;

}

 

    if (!get_magic_quotes_gpc()) {

        $albumName  = addslashes($albumName);

        $albumDesc  = addslashes($albumDesc);

    } 

 

$query = "INSERT INTO tbl_album (al_name, al_description, al_image, al_date)

  VALUES ('$albumName', '$albumDesc', '$newName', NOW())";

 

    mysql_query($query) or die('Error, add album failed : ' . mysql_error());                   

 

echo "<script>window.location.href='index.php?page=list-album';</script>";

exit;

}

?>

 

/////

 

Thanks!

 

Russ

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.