CodeIgniter Forums
Uploading text file without saving? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Uploading text file without saving? (/showthread.php?tid=72814)



Uploading text file without saving? - sing - 02-14-2019

I have a form and I want to upload text file and then read it and display the content on a textarea. The text is just a temp file so I don't want to save it.

Currently I am using the upload library like this

PHP Code:
$config['allowed_types'] = 'txt';
$config['max_size' '100';

$this->load->library('upload'$config);
$this->upload->initialize($config);

if ( ! 
$this->upload->do_upload()){
 
   $data['error'] = $this->upload->display_errors();
}
else{
 
   $text_file $this->upload->data();
 
   $data['$content'] = file_get_contents($text_file);
 
   echo "success";


I didn't specify the upload path in the config and want to only save the text to the temp folder. But that doesn't seems to work as it complains about invalid upload path.


RE: Uploading text file without saving? - salain - 02-14-2019

Hi,

If you don't want to save the file and only display it in the browser, you could use JavaScript to do it in the user's browser.
Have a look at this solution on StackOverFlow


RE: Uploading text file without saving? - sing - 02-14-2019

(02-14-2019, 11:15 PM)salain Wrote: Hi,

If you don't want to save the file and only display it in the browser, you could use JavaScript to do it in the user's browser.
Have a look at this solution on StackOverFlow

Hi, I would be running some filtering on the contents on the server side after upload, it's not just for display.