codeigniter framework upload save on linux mint - linux

I have below code running on apache on linux mint 64 bit OS. Find that files cannot save on server. Do you know how to solve? add more config or privileges??
$config['file_name'] = basename($imgPath);
$config['upload_path'] = $upload_dir;
$config['allowed_types'] = 'gif|jpg|png|bmp';
$this->upload->initialize($config);
if ( ! $this->upload->do_upload("image".$i))
or
$this->image_lib->clear();
$config2['image_library'] = 'gd2';
$config2['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config2['new_image'] = $upload_dir_resize.'/'.$thumb_fileName;
$config2['maintain_ratio'] = TRUE;
$config2['width'] = 320;
$config2['height'] = 320;
$this->image_lib->initialize($config2);
if ( !$this->image_lib->resize()){

You need to make sure you have 0777 rights on the folder you're saving.
if(!file_exists($folderPath))
mkdir($folderPath, 0777, TRUE);
$config['upload_path'] = $folderPath;
$config['file_name'] = randomStringName();
$config['allowed_types'] = 'jpg|png|bmp';
$config['max_size'] = '1024'; // 1MB~
$config['overwrite'] = FALSE;
if($this->upload->do_upload('image') == FALSE)
die('Ups...something went wrong');
$filePath = base_url() . $folderPath . $this->upload->data()['file_name'];

Related

error by using in PDFTron:' NetworkError(`Unsupported protocol ${this._url.protocol}`'

I trying to convert pdf file to pdfa3 file by using PDFTron.
I added current url_path.
the my code below:
var input_url = './utils/';
var input_filename = 'test.pdf';
var output_filename = 'test_pdfa.pdf';
var convert = true;
var pwd = '';
var exceptions;
var max_ref_objs = 10;
var url_input = input_url + input_filename;
console.log('Converting input document: ' + input_filename);
var pdfa = await PDFNet.PDFACompliance.createFromUrl(true, url_input, '', PDFNet.PDFACompliance.Conformance.e_Level2B, exceptions, max_ref_objs);
get error:
'NetworkError(Unsupported protocol ${this._url.protocol})',
Does anyone know what the problem is,
And why doesn't it recognize the location?
I changed the code to :
here.
Now it's working!!

How to solve the driver hanging on sending IRPs to delete EXE files which require Administrator authority?

I want to delete files by sending IRP via a WDK driver. It works well for deleting all files no matter *.pdf or *.pptx, except some EXEs which require Administrator to run, such as EXE installer and setup.exe etc. I don't know why it hangs on IoCallDriver once I try to delete EXE installers. I have also tried to set a timeout for KeWaitForSingleObject but no luck, the driver keeps hanging on IoCallDriver.
Does Windows limit drivers to remove these Administrator authority EXEs? How to solve this? Thanks a lot.
NTSTATUS send_delete_file_irp(PFILE_OBJECT file_object) {
KEVENT event;
PDEVICE_OBJECT device_object = IoGetBaseFileSystemDeviceObject(file_object);
PIRP irp = IoAllocateIrp(device_object->StackSize, false);
// Set the complete routine that will free the IRP and signal the event
KeInitializeEvent(&event, SynchronizationEvent, false);
IoSetCompletionRoutine(
irp,
io_complete,
&event,
true,
true,
true);
FILE_DISPOSITION_INFORMATION file_disposition;
file_disposition.DeleteFile = true;
IO_STATUS_BLOCK io_status_block;
irp->AssociatedIrp.SystemBuffer = &file_disposition;
irp->UserEvent = &event;
irp->UserIosb = &io_status_block;
irp->Tail.Overlay.OriginalFileObject = file_object;
irp->Tail.Overlay.Thread = (PETHREAD)KeGetCurrentThread();
irp->RequestorMode = KernelMode;
IO_STACK_LOCATION* stack_location = IoGetNextIrpStackLocation(irp);
stack_location->MajorFunction = IRP_MJ_SET_INFORMATION;
stack_location->DeviceObject = device_object;
stack_location->FileObject = file_object;
stack_location->Parameters.SetFile.Length = sizeof(FILE_DISPOSITION_INFORMATION);
stack_location->Parameters.SetFile.FileInformationClass = FileDispositionInformation;
stack_location->Parameters.SetFile.FileObject = file_object;
IoCallDriver(device_object, irp);
KeWaitForSingleObject(&event, Executive, KernelMode, true, nullptr);
return STATUS_SUCCESS;
}

Cannot place text inside file using linux

I have installed moodle in AWS EC2 instance. But config.php file is missing. And I created a file using **
touch config.php
** command. But I couldnt place my content inside that file.
My content is
<?php // Moodle configuration file
unset($CFG); global $CFG; $CFG = new stdClass();
$CFG->dbtype = 'mariadb'; $CFG->dblibrary = 'native'; $CFG->dbhost
= 'localhost'; $CFG->dbname = 'moodledb'; $CFG->dbuser = 'root'; $CFG->dbpass = 'pass'; $CFG->prefix = 'mdl_'; $CFG->dboptions = array ( 'dbpersist' => 0, 'dbport' => '', 'dbsocket' => '', 'dbcollation' => 'utf8mb4_general_ci', );
$CFG->wwwroot = 'http://localhost/moodle'; $CFG->dataroot = 'L:\\xampp\\moodledata'; $CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(__DIR__ . '/lib/setup.php');
I have connected to AWS using Putty from windows.
Use cat and heredoc:
cat > config.php <<'EOF'
your content
goes here
EOF
And you can skip touch this way.

Download files from connected FTP with Node.js

I'm rushing to find a solution for my problem!
At the moment I'm connected to an FTP and I selected 5 files to download, but I can't get the correct diretory for both local and remote path.
On the remote ftp, I am inside a folder named OUT and this folder contains 5 files that I want to download.
On local, I want to download to my project folder > files.
Here is my code:
ftps.cd('./OUT')
.raw('ls')
.exec(function(err, res){
var arr = [];
var items = res.data.split('\n')//.map(String);
var item;
//console.log(items);
for (i in items){
item = items[i];
if(item.length > 0 ){
var linha = item.toString().slice(46);
var date = linha.toString().substr(0,12);
var date_timestamp = moment([2018, months[date.substr(0,3)], date.substr(7,2), date.substr(5,2), date.substr(10,2)]).format('x');
var nome_ficheiro = linha.toString().slice(13);
// console.log(nome_ficheiro)
// split files
//-rwxrwxrwx 1 owner group 79563 Jul 17 10:44 STKHYN_20180713170017.csv
var fl = [];
// fl['datea'] = moment([2018, months[date.substr(0,3)], date.substr(7,2), date.substr(5,2), date.substr(10,2)]);
fl['date'] = date_timestamp;
fl['filename'] = nome_ficheiro;
arr.push(fl);
}
}
// filter array
arr = _.sortBy(arr, "date").reverse();
// first 5 files
arr = arr.splice(0,5);
// get files
for (i in arr){
ftps.put("files/text.txt", "/");
ftps.get(arr[i]['filename']);
}
console.log(arr);
});
Could you guys please help me?

count images in local folder WinRT

I am new in WinRT ,
Is it possible to count number of images in Assest Folder . So that we can do few operation over it .
Presently i am making a small app.
Thanks in advance
try,
var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Assets");
var files = await folder.GetFilesAsync();
and get the files count as
var filesCount = files.Count;
and you can get the files count of specific extension as
var pngFileCount = files.Where(file => file.FileType == ".png").Select(f => f).ToList().Count;
Hope this will helps you :)
Here you go.
var folder = await Package.Current.InstalledLocation.GetFolderAsync("Assets");
var options = new QueryOptions { FileTypeFilter = { ".png", ".jpg" } };
var query = folder.CreateFileQueryWithOptions(options);
var files = await query.GetFilesAsync();
foreach (var file in files)
{
// TODO
}
I want to point out that this works in Windows but not Windows Phone. Not yet.
Best is luck.

Resources