Welcome Guest, Not a member yet? Register   Sign In
Uploading text file without saving?
#1

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.
Reply
#2

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
A good decision is based on knowledge and not on numbers. - Plato

Reply
#3

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB