简体   繁体   English

文件上传后codeigniter重定向

[英]codeigniter redirect after file upload

1) situation: On some page the user can use an file upload form to upload a text (or excel) file. 1)情况:在某些页面上,用户可以使用文件上传表单来上传文本(或excel)文件。 After successful upload the user should be redirected to a page where he can do whatever with his file. 成功上传后,应将用户重定向到页面,在该页面上他可以使用文件进行任何操作。

2) My controller class: 2)我的控制器类:

...
if (!$this->upload->do_upload('fileupload')) {
            echo "error file upload not successfull";
   }else {
       redirect('import/filepreview/');
   }

3) what happens 3)会发生什么

First nothing appears to happen. 首先似乎什么也没发生。 The file has been uploaded but the page doesn't change. 文件已上传,但页面未更改。 While using firebug extension it appears there has been sent a Header containing a get request to the proper target url and all the expected content is in the answer. 使用Firebug扩展程序时,似乎已发送了一个标头,其中包含对正确的目标url的get请求,并且所有预期的内容都在答案中。 But not displaying on site. 但不在现场显示。

I actually don't know what I am doing wrong. 我实际上不知道我在做什么错。

Solved the problem but only using a workaround. 解决了问题,但仅使用了解决方法。 Finally I used javascript redirection 最后,我使用了javascript重定向

window.location.replace(" http://new.../x_id "); window.location.replace(“ http://new.../x_id ”);

with an x_id which the servers answer to the file upload. 服务器使用x_id响应文件上传。

So everything works fine for me. 所以一切对我来说都很好。 But the original question, why CI's redirect does not work is still open for me. 但是最初的问题,为什么CI的重定向不起作用,仍然对我开放。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM