[solved] Upload file but don't save it. |
[eluser]Ñuño Martínez[/eluser]
Hi people. I'm working with a controler that process a file uploaded by the user. The file will not be stored at the server, it will be loaded and processed. I know I can use the file uploading class, store the file on a temporary place, open it, load it, process it and delete it. The key here is the file would be pretty big so if I can access directly to the $_FILE['_name_']['tmp_name'] file and avoid the "temporary storage" I think it will be much faster and efficient. Is there a way to do that?
[eluser]pistolPete[/eluser]
Quote:if I can access directly to the $_FILE[‘_name_’][‘tmp_name’]Why don't you do so using plain PHP? If you want to use the upload class you'd have to extend it not to move the uploaded temp file. You can access the temp file using: Code: $this->upload->file_temp
[eluser]xwero[/eluser]
And it's not a good idea to process the temporary file because it lives in a directory that gets cleaned if the maximum limit for that directory is reached. This means at some point files will get lost instead of a warning you get when you run out of disk space.
[eluser]Ñuño Martínez[/eluser]
[quote author="pistolPete" date="1236275205"]Why don't you do so using plain PHP?[/quote] I tried this: Code: if (isset ($_FILE))
[eluser]Ñuño Martínez[/eluser]
[quote author="xwero" date="1236275406"]And it's not a good idea to process the temporary file because it lives in a directory that gets cleaned if the maximum limit for that directory is reached. This means at some point files will get lost instead of a warning you get when you run out of disk space.[/quote]PHP's help says <i>"The file will be deleted from the temporary directory at the end of the request if it has not been moved away or renamed"</i>. I think it's enough, isn't it?.
[eluser]pistolPete[/eluser]
Did you load the upload class? Is your upload field called "archivo_csv" ? Try this for debugging: Code: echo '<pre>'.print_r($_FILE,TRUE).'</pre>';
[eluser]Ñuño Martínez[/eluser]
I'd find a mistake. I used "$_FILE" and should be "$_FILES" (thanks xwero). Now I fixed that but didn't work. The form is: Code: <form action="/archivo_csv_seur" method="post" The controler code is: Code: echo '<pre>'.print_r ($_FILES, true).'</pre>'; The first "echo" allways returns an empty array.
[eluser]pistolPete[/eluser]
Code: <input id="archivo_csv" type="file" class="input a250" />
[eluser]Yman[/eluser]
hi guys, if i use Code: $this->upload->file_temp do i have to define "upload_path" as well? |
Welcome Guest, Not a member yet? Register Sign In |