Skip to content

Commit 96c1009

Browse files
cheeseeatercheeseeater
authored andcommitted
Temporary missing file extention bug fix
The name of the asset was not being prefixed before the file extention causing files to be unrecognisable when downloaded. This temporary fix removes the asset name altogether, replacing it with a static name. This file should be updated futher down the line so that asset names are in the download name. The ability to download GIFs has also been implemented.
1 parent 65a222c commit 96c1009

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

public_html/uploads/download.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ function addFile($zip, $filename, $localname){
8686
function closeAndPrint($zip, $tmpname){
8787
$res = $zip->close();
8888
if($res === FALSE) dieWith500();
89-
89+
9090
sendHeaders();
9191
header("Content-Length: " . filesize($tmpname));
92-
92+
9393
readfile($tmpname);
94-
94+
9595
unlink($tmpname);
9696
}
9797

@@ -103,21 +103,24 @@ function getScript($filename){
103103
if($asset['assetType'] == "script"){
104104
$tmp = newTempZip("../assets/sb2/default.sb2");
105105
$zip = zipOpen($tmp);
106-
106+
107107
$project = getProjectJson($zip);
108108
$project['children'][0]['scripts'] = array(array(0, 0, getScript($file_url)));
109-
109+
110110
setProjectJson($zip, $project);
111-
112-
header("Content-disposition: attachment; filename=\"" . $asset[0]['customName'] . ".sb2\"");
113-
111+
112+
header("Content-disposition: attachment; filename=" . 'OpenSprites-Script-Download' . ".sb2");
113+
114114
closeAndPrint($zip, $tmp);
115115
} else if($ext == "gif") {
116-
// todo: implement
116+
sendHeaders();
117+
header('Content-Length: ' . filesize($file_url));
118+
header("Content-disposition: attachment; filename=" . 'OpenSprites-Gif-Download' . '.' . ".gif");
119+
readfile($file_url);
117120
} else {
118121
sendHeaders();
119122
header('Content-Length: ' . filesize($file_url));
120-
header("Content-disposition: attachment; filename=\"" . $asset[0]['customName'] . '.' . $ext . "\"");
123+
header("Content-disposition: attachment; filename=" . 'OpenSprites-Download' . '.' . $ext);
121124
readfile($file_url);
122125
}
123-
?>
126+
?>

0 commit comments

Comments
 (0)