简体   繁体   English

Codeigniter,GroceryCRUD,GoDaddy-文件上传错误

[英]Codeigniter, GroceryCRUD, GoDaddy - file upload error

I have a controller in CI which allows me to upload files to my database. 我在CI中有一个控制器,该控制器使我可以将文件上传到数据库。 It works fine locally. 它在本地工作正常。 I setup CI on GoDaddy, changed permissions, changed database configs etc. 我在GoDaddy上设置了CI,更改了权限,更改了数据库配置等。

Now when I try to upload a file, I can select the file and it gets to 100% uploaded -- but it doesn't save. 现在,当我尝试上传文件时,我可以选择该文件,并且该文件会100%上传-但不会保存。 Permissions on the directory files get uploaded to are 777 (for testing right now). 上传到目录文件的权限为777(立即测试)。 I get the following in the webdev console: 我在webdev控制台中得到以下内容:

Error in event handler for (unknown): TypeError: Cannot read property 'state' of null
    at CSRecorder.onQueryStateCompleted (chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:45:13)
    at extensions::messaging:327:9
    at Function.target.(anonymous function) (extensions::SafeBuiltins:19:14)
    at Event.dispatchToListener (extensions::event_bindings:386:22)
    at Event.dispatch_ (extensions::event_bindings:371:27)
    at Event.dispatch (extensions::event_bindings:392:17)
    at dispatchOnMessage (extensions::messaging:294:22) extensions::event_bindings:375
GET http://mywebsite.com/index.php/assets/uploads/files/dark_bg.png 404 (Not Found) jquery-1.10.2.min.js:4
event.returnValue is deprecated. Please use the standard event.preventDefault() instead. 

I also get a popup that says "The page at mywebsite.com says: 6" . 我还得到一个弹出窗口,显示"The page at mywebsite.com says: 6"

Here is the controller (again, it's working on my local Windows machine): 这是控制器(同样,它在我的本地Windows计算机上运行):

public function photo_upload()
    {
        try{

            $gc = new grocery_CRUD;

            $gc->set_table('photography')
                ->set_subject('Image')
                ->required_fields('image_path')
                ->columns('image_path','image_name');

            $gc->set_field_upload('image_path','assets/uploads/files');
            $gc->unset_fields(array('image_date','image_extension'));
            $gc->change_field_type('image_name','invisible');
            $gc->callback_before_insert(array($this,'rename_image'));

            $output = $gc->render();

            $this->_example_output($output); 
        }catch(Exception $e){
                show_error($e->getMessage().' --- '.$e->getTraceAsString());
            }       
    }

function rename_image($post_array) 
    {
        if (!empty($post_array)) {
            //Remove image extension from image name
            $img_name = preg_replace('/\.[^.]+$/', '', $post_array['image_path']);
            //Remove codeigniter id from image name
            $img_name = substr($img_name, 6);
            $post_array['image_name'] = $img_name;
            return $post_array;
        }
    }

Are you 100% sure the directory exists and the image_path you are pointing to exists? 您是否100%确定目录存在并且您指向的image_path存在?

$gc->set_field_upload('image_path','assets/uploads/files');

You could set an absolute path for that: 您可以为此设置绝对路径:

$gc->set_field_upload('image_path',BASEPATH.'assets/uploads/files');

And can you tell me what your CI error logs say? 您能告诉我您的CI错误日志说什么吗? In application/logs/log-*.php What i don't understand about the error you are getting is the error popup doesn't seem to be coming from this piece of code. 在application / logs / log-*。php中,我对您所得到的错误不了解的是错误弹出窗口似乎并非来自这段代码。 I was expecting this message to popup: 我期待此消息弹出:

show_error($e->getMessage().' --- '.$e->getTraceAsString());

But instead you get: "The page at mywebsite.com says: 6" . 但是,您却得到: "The page at mywebsite.com says: 6"

Check your current working dir with getcwd(). 使用getcwd()检查当前的工作目录。 Did you develop the site on your local machine from a subdirectory eg mydomain.com/dev and now on your actual hosting you are running it from a root directory like mydomain.com/ ? 您是否从子目录(例如mydomain.com/dev)在本地计算机上开发了站点,而现在在实际主机上,您正在从根目录(例如mydomain.com/)运行该站点? If it is, your 如果是这样,您的

$gc->set_field_upload('image_path','assets/uploads/files');

might actually need an additional / in the path.. If not, show us the output of: 可能实际上需要在路径中添加一个/。如果不需要,请向我们显示以下输出:

echo getcwd() . 回声getcwd()。 "
"; and the full path from any ftp client to the assets/uploads/files. Execute the getcwd() command in the foto_upload method to make sure you are seeing the actual path CI is currently working from. “;以及从任何ftp客户端到资产/上传/文件的完整路径。执行foto_upload方法中的getcwd()命令以确保您看到的是CI当前正在使用的实际路径。

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

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