我有一个网站,允许用户上传文件。当在另一个页面上载文件时,用户可以下载该文件。问题是如果文件名中有一个空格,则只会选取第一个作业而不是整个文件名。我想知道是否有一种方法可以下载带有空格的文件,或者一个简单的选项可能是将下划线添加到文件名以便下载。用Underscore替换空格,以便我可以下载文件。
//This is the directory where images will be saved
$target = "../images/avatars/";
$target = $target . basename($_FILES['photoLocation']['name']);
// Check to see all fields have been completed
$photoLocation =($_FILES['photoLocation']['name']);
if (!empty($photoLocation))
{
// Create an SQL query to add the comment
$sql = "INSERT INTO tblPhotoUpload (photoLocation) VALUES ('$photoLocation')";
// Connect to the database
connect();
// Run the query and store the result in a variable
$result = mysql_query($sql) or die("Could not run query");
//Writes the photo to the server
if(move_uploaded_file($_FILES['photoLocation']['tmp_name'], $target))
// Close connection to the database
mysql_close()
而我正在显示这样的文件。
while($record = mysql_fetch_array($result))
{
?>
<tr class="row">
<td class="cell"><a href= http://xxxxxxxxxxxxxxxxxxxxxx.com/images/avatars/<?php echo $record["photoLocation"];?>>Download</a> </td>
感谢大家在这么快的时间回复。我已经找到了答案,我已经打勾了。 很多你说过一些很棒的东西给我考虑。 谢谢你们 – user1775454 2013-02-11 13:42:54