slight problem with naming files in php gallery
Posted: Tue Aug 05, 2008 1:28 pm
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
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