[SOLVED] Spaces getting inserted before & after filename
Posted: Sat May 14, 2005 11:17 am
I'm working on a very small database where I am uploading data and an image. For some reason a space is getting inserted immediately before and after the image filename, and I can't figure out how it's happening so that I can get rid of them.
UPLOAD CODE:
DISPLAY UPLOADED INFORMATION CODE:
When I display the information, however, the photos don't appear. When I look at the source code that is generated, it reads as follows:
Any help would be sincerely appreciated.
UPLOAD CODE:
Code: Select all
if($HTTP_POST_VARS['Upload'] == "Upload"){
}
if($_POST['Upload'] == "Upload"){
$originalImageFileName = $_FILES['StaffPhoto']['name'];
$tempImageFileName = $_FILES['StaffPhoto']['tmp_name'];
$siteRoot = $_SERVER["DOCUMENT_ROOT"];
$uploadDir = $siteRoot . "/test2/";
$newImagePath = "/test2/staff/" . $originalImageFileName;
umask(0);
move_uploaded_file($tempImageFileName, $newImagePath);
system("chmod 755 $newPath");
$query = "INSERT INTO staff (
StaffName, StaffTitle, StaffPhoto)
VALUES (' " . $_POST['StaffName'] . " ', ' " . $_POST['StaffTitle'] . " ', ' " . $_FILES['StaffPhoto']['name'] . " ')";
$result = mysql_query($query);
$lastInserted = mysql_insert_id();
}
?>Code: Select all
$query = "SELECT * FROM staff";
$result = mysql_query($query) or die("Error: " . mysql_error());
$row = mysql_fetch_array ($result); // retrieve information
while($row = mysql_fetch_array($result)){
echo '<table width="400" border="0" cellspacing="0" cellpadding="5">
<tr class="bodytext">
<td align="left">' . $row['StaffName'] . '<br>
' . $row['StaffTitle'] . '</td>
<td align="center"><img src="staff/' . $row["StaffPhoto"] . '"></td>
</tr>
</table>';
}
mysql_free_result($result);Code: Select all
<img src="e;staff/ filename.jpg "e;>