Reputation: 40291
I installed Uploadify UI on my site so I can allow user to upload files to my site. It is working now but the problem is that it uploads files sometimes and sometimes it does not. So I can upload an png file and it will work no problems. but when I upload excel file it will allow some to be uploaded and some it work allow it.
I am not sure what can I check to see what is causing the issue.
I have tried to turn the debuger on 'debug' : true but that did not give me any clues. I also looked at my php logs and there was no error/warnings there.
I am not sure what else I can check but I will apreshiate any type of help with this.
Here is my javascript code to set it up
<?php $timestamp = time();?>
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'formData' : {
'timestamp' : '<?php echo $timestamp;?>',
'token' : '<?php echo md5($timestamp);?>',
'upload_path': 'ticketing_center/',
'allowed_extentions': 'jpg,jpeg,gif,PNG,JPG,png,JPEG, jpeg,zip,rar,doc,docx,cvs,xls,xlsx,txt'
},
'auto' : true,
'debug' : true,
'swf' : '../../includes/uploadify.swf',
'uploader' : '../../includes/uploadify.php',
'fileSizeLimit' : '50MB',
'fileTypeExts' : '*.gif; *.jpg; *.JPG; *.png; *.PNG; *.JPEG; *.jpeg; *.zip; *.rar; *.doc; *.docx; *.cvs; *.xls; *.xlsx; *.txt;',
'onUploadSuccess' : function(file, data, response) {
if(data != 'INVALID'){
$('#attached_files').append('<input type="hidden" name="attachments[]" value="'+ $.trim(data) +'" />');
} else {
alert('Invalid File Type');
}
}
});
});
</script>
the following is my PHP script
<?php
$targetFolder = '';
$verifyToken = '100';
$actualToken = '';
$fileTypes = array('jpg','jpeg','gif','png');
if(isset($_POST['upload_path'])){
$targetFolder = $_POST['upload_path'];
}
if(isset($_POST['timestamp'])){
$verifyToken = md5($_POST['timestamp']);
}
if(isset($_POST['token'])){
$actualToken = $_POST['token'];
}
if(isset($_POST['allowed_extentions'])){
$types = explode(',', $_POST['allowed_extentions']);
if(count($types) > 0 ){
$fileTypes = $types;
}
}
if (!empty($_FILES) && $actualToken == $verifyToken) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetPath = ROOT_FIXED . UPLOAD_DIR . $targetFolder; //$_SERVER['DOCUMENT_ROOT']
$targetPath = str_replace( "//", "/", $targetPath);
$new_filename = USER_ID . '_' . time() . '_' . str_replace(" ", "_", $_FILES['Filedata']['name']);
$targetFile = $targetPath . $new_filename;
// Validate the file type
//$fileTypes = array('jpg','jpeg','gif','png'); // File extensions
$fileParts = pathinfo($new_filename); //str_replace(" ", "_", $_FILES['Filedata']['name'])
if (in_array($fileParts['extension'],$fileTypes)) {
move_uploaded_file($tempFile,$targetFile);
echo trim($new_filename);
} else {
echo 'INVALID';
}
}
?>
Thanks for your time and help
Upvotes: 0
Views: 234
Reputation: 40291
I don't understand why people vote your questions down without a comment that will help you understand why. but any way to help other that will run into the same issue. Here is the solution
the configuration in my php.ini file were set to a low limites. Max upload file was set to 2M
go to php.ini and find the
upload_max_filesize - set to 50M
post_max_size - set to 50M
max_execution_time - set to 120
max_input_time - set to 50
Restart our apache and now you should be able to upload files up to 50MB in size
Upvotes: 1