我有一個網站,允許用戶上傳文件。當在另一個頁面上載文件時,用戶可以下載該文件。問題是如果文件名中有一個空格,則只會選取第一個作業而不是整個文件名。我想知道是否有一種方法可以下載帶有空格的文件,或者一個簡單的選項可能是將下劃線添加到文件名以便下載。用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