所以我有一個腳本來下載一個視頻文件,由於某種原因,它不工作。 id,firstname和lastname變量來自另一個PHP腳本,它將值從數據庫中提取出來,並使用url中的變量打開這個下載腳本。我的文件正在使用錯誤的名稱進行下載。請幫我修復我的PHP
好的,這樣的問題。到目前爲止,一切正常,但是當下載文件時,它們都被稱爲-audio.wav和-video.webm。請幫忙,因爲我在這方面遇到了很大的麻煩,這將解決一個大問題。
的下載腳本:
<?php
$id = $_POST['id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$fileNameVideo = $firstname.$lastname."-video.webm";
$filePathVideo = 'videos/' . $fileNameVideo;
if (!file_exists($filePathVideo)) {
echo "<h1>Error Downloading ".$fileNameVideo." ".$php_errormsg."</h1><br>";
return;
}
header("Content-disposition: attachment; filename=" . $fileNameVideo);
header("Content-type: application/pdf");
readfile($filePathVideo);
echo "<h1>".$fileNameVideo." Downloaded</h1><br>";
?>
打開下載頁面的腳本:
<?php
include 'upload/connection.php';
$conn = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$conn) {
die("CONNECTION ERROR: " . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $conn);
if(!$db_selected) {
die(DB_NAME .' is not available. ERROR: '. mysql_error());
}
$result = mysql_query("SELECT id, fullname, grade, email, sendemail, send, invid, firstname, lastname FROM info WHERE invid = 1 ORDER BY id DESC");
while ($row = mysql_fetch_array($result)) {
$id = $row{'id'};
$firstname = $row{'firstname'};
$lastname = $row{'lastname'};
echo "<script>window.open('download-video.php?id=".$id."&firstname=".$firstname."&lastname=".$lastname."', '_blank');window.open('download-audio.php?id=".$id."&firstname=".$firstname."&lastname=".$lastname."', '_blank');</script>";
}
mysql_close();
?>
由於某種原因,我的代碼複製錯誤。我正在更新它。 – lucadem1313
@ lucadem1313再次GET NOT POST – 2015-11-14 00:22:22
對不起。感謝您的幫助 – lucadem1313