Skip to content

Commit

Permalink
Fixing some upload problems
Browse files Browse the repository at this point in the history
  • Loading branch information
mennodekker committed Aug 21, 2012
1 parent 6ba996f commit 19bf03e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
7 changes: 6 additions & 1 deletion application/controllers/UploaderController.php
Expand Up @@ -33,7 +33,7 @@ function run()
elseif(substr($sFileName,0,3)=='fu_'){
$sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
}
header('Content-Type: '.mime_content_type($sFileDir.$sFileName));
header('Content-Type: '. CFileHelper::getMimeType($sFileDir.$sFileName));
readfile($sFileDir.$sFileName);
exit();
}
Expand Down Expand Up @@ -103,6 +103,11 @@ function run()
$clang = Yii::app()->lang;

$sTempUploadDir = $tempdir.'/upload/';
// Check if exists and is writable
if (!file_exists($sTempUploadDir)) {
// Try to create
mkdir($sTempUploadDir);
}
$filename = $_FILES['uploadfile']['name'];
$size = 0.001 * $_FILES['uploadfile']['size'];
$valid_extensions = strtolower($_POST['valid_extensions']);
Expand Down
1 change: 1 addition & 0 deletions application/helpers/qanda_helper.php
Expand Up @@ -2867,6 +2867,7 @@ function upload_$ia[1]() {
headFileName: '" . $clang->gT('File name','js') . "'
};
var imageurl = '".Yii::app()->getConfig('imageurl')."';
var uploadurl = '".$scriptloc."';
</script>\n";
header_includes(Yii::app()->getConfig('generalscripts')."modaldialog.js");

Expand Down
4 changes: 2 additions & 2 deletions scripts/modaldialog.js
Expand Up @@ -179,14 +179,14 @@ function displayUploadedFiles(jsonstring, filecount, fieldname, show_title, show
if (pos)
{
if (isValueInArray(image_extensions, jsonobj[i].ext))
display += '<tr><td class="upload image"><img src="/uploader/index/sid/'+surveyid+'/filegetcontents/'+decodeURIComponent(jsonobj[i].filename)+'" height=100px /></td>';
display += '<tr><td class="upload image"><img src="' + uploadurl + '/sid/'+surveyid+'/filegetcontents/'+decodeURIComponent(jsonobj[i].filename)+'" height=100px /></td>';
else
display += '<tr><td class="upload placeholder"><img src="'+imageurl+'/placeholder.png" height=100px /></td>';
}
else
{
if (isValueInArray(image_extensions, jsonobj[i].ext))
display += '<tr><td class="upload image"><img src="/uploader/index/filegetcontents/'+decodeURIComponent(jsonobj[i].filename)+'" height=100px /></td>';
display += '<tr><td class="upload image"><img src="' + uploadurl + 'filegetcontents/'+decodeURIComponent(jsonobj[i].filename)+'" height=100px /></td>';
else
display += '<tr><td class="upload placeholder"><img src="'+imageurl+'/placeholder.png" height=100px /></td>';
}
Expand Down

0 comments on commit 19bf03e

Please sign in to comment.