Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

File is not a valid upload


Reply

23 Posts   3978 Views

Avatar
Josua

13 January 2012 at 8:18am Community Member, 86 Posts

I found where is the problem. It's a SilverStripe bug. :(
After using move_uploaded_file (AssetAdmin.php Line:225) the is_uploaded_file function (Upload.php Line: 480) return false.
is_uploaded_file function should be used with the original path and name of the uploaded file.

Therefore, this check should be removed from the validate() function (Upload.php) and included in the doUpload($data, $form) function (AssetAdmin.php).

Are you going to solve this problem in a new version?
Can I expect a new version soon?

Thank you very much.

Regards,
Jose A.

Avatar
Josua

13 January 2012 at 9:43am (Last edited: 13 January 2012 9:54am), Community Member, 86 Posts

More problems. :(

If I add in mysite/_config.php:
File:: $ apply_restrictions_to_admin = false;

and try to upload an image through the CMS. It produces the following error:

[User Error] Folder::addUploadToFolder: Couldn't copy '/var/www/vhosts/dominiox.com/httpdocs/silverstripe-cache/bar1111.jpg' to '/var/www/vhosts/dominiox.com/httpdocs/assets/Uploads/bar1111.jpg'
POST /admin/assets/UploadForm

Line 260 in /var/www/vhosts/dominiox.com/httpdocs/sapphire/filesystem/Folder.php

I have to say that the bar1111.jpg file has been moved successfully to silverstripe-cache folder and is in it.
The problem comes when SilverStripe try to move the file from silverstripe-cache folder to assets/Uploads folder.

I think the problem is the internal check of the move_uploaded_file function, similar to the is_uploaded_file function.

The documentation says (move_uploaded_file):
This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

As the file (bar1111.jpg) has been moved from its original position (/temp), checking POST upload mechanism fails.

What version of SilverStripe is based the demo? http://demo.silverstripe.org
There, CMS Files & Images section is working properly.
Why?

Am I doing something wrong? :(

Please, if someone knows a solution for this.....

Thanks,

Regards,
Jose A.

Avatar
Josua

13 January 2012 at 10:25pm Community Member, 86 Posts

I've seen the bug can be fixed using this patch:
http://open.silverstripe.org/attachment/ticket/5547/2.4.1-FileUpload-2.diff

but, why has not fixed in version 2.4.6 of SilverStripe?

Regards,

Jose A.

Avatar
Josua

14 January 2012 at 2:51am Community Member, 86 Posts

Is not there someone of SilverStripe team to answer the question?

Thanks,

Jose A.

Avatar
Josua

17 January 2012 at 12:22am Community Member, 86 Posts

How strange!
Does nobody answer? :(

Regards,
Jose A.

Avatar
Funfair77

17 January 2012 at 2:24am (Last edited: 17 January 2012 2:24am), Community Member, 49 Posts

Hello Jose,

Maybe when you start a new topic they give us feedback.

Marnix

Avatar
Josua

17 January 2012 at 5:14am Community Member, 86 Posts

I will open a new topic.

Thanks Marnix,

Regards,