Blog-plugin: Error uploading file ... copy(): Filename cannot be empty

Created on 14 Nov 2016  路  13Comments  路  Source: rainlab/blog-plugin

I got an error when click or drag an image to the post.

Any help here, please?

Medium Review Needed Maintenance

Most helpful comment

Thanks, this works great. But because this fix is not yet in october/rain/src/Database/Attach/File.php. It will still break for those attachment.

Inherit this class and override the function with the one in the patch.
Now I can use October on my client's aging Windows server.

public function fromPost($uploadedFile)
{
    if ($uploadedFile === null) {
        return;
    }

    $this->file_name = $uploadedFile->getClientOriginalName();
    $this->file_size = $uploadedFile->getClientSize();
    $this->content_type = $uploadedFile->getMimeType();
    $this->disk_name = $this->getDiskName();

    $realPath = empty(trim($uploadedFile->getRealPath()))
        ? $uploadedFile->getPath() . DIRECTORY_SEPARATOR . $uploadedFile->getFileName()
        : $uploadedFile->getRealPath();

    $this->putFile($realPath, $this->disk_name);

    return $this;
}

But for everything else like, Avatar that uses the previous function, will still face the same error. Only MediaManager or those using patched class can upload fine on Windows IIS.

All 13 comments

Does this only happen in the blog plugin? Try uploading your avatar in the back-end to see if the same issue occurs. This is most likely something caused by your hosting provider, check the error logs for more details.

Otherwise as per the contribution guidelines, please provide the exact steps you are taking for the issue to occur. This will be used for peer review.

Hi Samuel,

thank you for your quickly reply.

I have tried to upload my avatar picture and I got the same error.

do you know how to fix it? my octobercms is installed on windows server 2012.

Looking forward for your help.

Regards,

Fabio


From: Samuel Georges [email protected]
Sent: Monday, November 14, 2016 9:41 PM
To: rainlab/blog-plugin
Cc: fcidral; Author
Subject: Re: [rainlab/blog-plugin] Error uploading file ... copy(): Filename cannot be empty (#257)

Does this only happen in the blog plugin? Try uploading your avatar in the back-end to see if the same issue occurs. This is most likely something caused by your hosting provider, check the error logs for more details.

Otherwise as per the contribution guidelineshttps://github.com/octobercms/october/blob/master/CONTRIBUTING.md#reporting-a-bug-with-octobercms, please provide the exact steps you are taking for the issue to occur. This will be used for peer review.

You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/rainlab/blog-plugin/issues/257#issuecomment-260456084, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AWYCLxVCZ-c7zFNw5SLrkwTgVgIW4jF-ks5q-MdigaJpZM4KxyHj.

@tschallacka is our resident Windows Server user. Any idea why this might be happening, Tschallacka?

yup, I know this error. I need to find the fix for it. be back soon

@tschallacka had a PR (https://github.com/octobercms/october/pull/1871/) made to potentially resolve the issue, but it was closed due to lack of revision to meet the repository's standards. If anyone wants to try again, they're welcome to.

@fcidral If I reimplement the changes from octobercms/october#1871 will you test to ensure it works for you?

@fcidral Please confirm that octobercms/october#2654 fixed this for you

Try this one out: https://github.com/octobercms/october/pull/2674

That one is the fix for the images alone.

Thanks, this works great. But because this fix is not yet in october/rain/src/Database/Attach/File.php. It will still break for those attachment.

Inherit this class and override the function with the one in the patch.
Now I can use October on my client's aging Windows server.

public function fromPost($uploadedFile)
{
    if ($uploadedFile === null) {
        return;
    }

    $this->file_name = $uploadedFile->getClientOriginalName();
    $this->file_size = $uploadedFile->getClientSize();
    $this->content_type = $uploadedFile->getMimeType();
    $this->disk_name = $this->getDiskName();

    $realPath = empty(trim($uploadedFile->getRealPath()))
        ? $uploadedFile->getPath() . DIRECTORY_SEPARATOR . $uploadedFile->getFileName()
        : $uploadedFile->getRealPath();

    $this->putFile($realPath, $this->disk_name);

    return $this;
}

But for everything else like, Avatar that uses the previous function, will still face the same error. Only MediaManager or those using patched class can upload fine on Windows IIS.

Thanks for reporting that, I'll fix it for you in the library repository as well.

@shoguniphicus I've added the fix to the library as well in https://github.com/octobercms/library/commit/aeacd00c4dab4e054d15f79e41049b832efa1948. Does that solve your problems now?

Since @shoguniphicus never replied, and neither did @fcidral I'm going to assume that is issue is resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rickmills picture rickmills  路  5Comments

silasrm picture silasrm  路  4Comments

HitArrowLegend picture HitArrowLegend  路  6Comments

petehalverson picture petehalverson  路  3Comments

karnold picture karnold  路  5Comments