File is missing after a "successful" file upload (using the fuelphp framework)

StackOverflow https://stackoverflow.com/questions/20338002

  •  07-08-2022
  •  | 
  •  

質問

I'm trying to implement image uploads for an app built with FuelPHP. The images are not tied to any models. I'm basically trying to upload to DOCROOT.files.

The upload seems to work fine but when I navigate to the actual directory on the server, it is empty. I get no errors. the var_dump for $file from Upload::get_files() was (hello is the app name):

array(12) { ["field"]=> string(8) "filename" ["saved_as"]=> string(13) "testphoto.jpg" ["name"]=> string(13) "testphoto.jpg" ["type"]=> string(10) "image/jpeg" ["file"]=> string(14) "/tmp/phpKNmO26" ["error"]=> bool(false) ["size"]=> int(76613) ["extension"]=> string(3) "jpg" ["basename"]=> string(9) "testphoto" ["mimetype"]=> string(10) "image/jpeg" ["saved_to"]=> string(36) "/home/user/www/hello/public/files/" ["errors"]=> array(0) { } }

The controller code is this:

class Controller_PhotoUpload {
    public function upload_image()  {
        // Custom configuration for this upload
        $config = array(
            'path' => DOCROOT.'files',
            'ext_whitelist' => array('img', 'jpg', 'jpeg', 'gif', 'png'),   
            'max_size' => 1048576, //1mb
        );
        // process the uploaded files in $_FILES
        Upload::process($config);
        // if there are any valid files
        if (Upload::is_valid()) {
            // save them according to the config
            Upload::save();
            foreach(Upload::get_files() as $file){
                var_dump($file);    // do something with the file info
            }
        }else{
        }
        // and process any errors
        foreach (Upload::get_errors() as $file){
            var_dump($file);
        }
    }
}

This controller code is being executed on form submission.

Do you think this code has problems or do you think it's a server issue?

thanks!

役に立ちましたか?

解決

oops had to chmod 0777 on the file directory

so it was a server permission.

The lack of an error was a FuelPHP glitch.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top