문제

i want to move a uploaded file locate in public:// to a folder inside mymodule.

I try

$dirname = dirname(__file__);
$fullpath = strpos($dirname, '\\') === false ? $dirname . '/' . $file->filename : $dirname . '\\' . $file->filename;
$go = file_move($file, $fullpath);

and i got this error

The specified file public://xxx.BMP could not be moved, because the destination is invalid. More information is available in the system log.

But de $destination is valid and is mymodule's folder!!

Can anyone helpme to move-it?

Thanks!!!

도움이 되었습니까?

해결책

Generally, moving files to the module folder isn't good idea. But, if you want to do this, use path, relative to drupal root or absolute file path. Also, check folder permission for your module's directory (by default, module folders is read-only). If this not helps, i recommend you to check system log for more detailed error explanation.

다른 팁

Best is to move the files in public://

$dest = 'public://';
$file = file_move($file, $dest)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top