PivotX 2.2.2 Image Upload does not work

This is the place to discuss bugs that have been found in the most recent version of PivotX. Posting bugs will ensure that the Development Team is aware of them and that they will be addressed when resources are available.

Re: PivotX 2.2.2 Image Upload does not work

Postby Logfather » Tue Mar 15, 2011 4:03 pm

I'm gonna shoot myself in the face:

A) there's nothing to show really, how am I gonna show AN IMAGE NOT BEING THERE?

B) I just got this from the host:
Dit klopt. De server is uitgerust met de module suPHP. Deze zorgt er voor dat onze server veilig blijft en er niet zomaar bestanden kunnen worden geupload middels lekke websites. Deze instelling is voor de gehele server gelijk en kunnen wij geen uitzondering op maken.


In English this means

Our servers have the suPHP module, it means files cannot be uploaded through 'shabby' websites'.


WTF does this even mean? :P I'm gonna tell the guy I'm helping out to find a real host I guess. I guess it does mean it's a Pivot (2.2.5) problem because we haven't had this nonsense going on before we got to 2.2.4 and eventually 2.2.5.

@Bob Firefox latest and IE7.
Logfather
 
Posts: 163
Joined: Sun Jul 12, 2009 9:29 am
Location: Amsterdam

Re: PivotX 2.2.2 Image Upload does not work

Postby Bob » Tue Mar 15, 2011 4:39 pm

WTF does this even mean? I'm gonna tell the guy I'm helping out to find a real host I guess. I guess it does mean it's a Pivot (2.2.5) problem because we haven't had this nonsense going on before we got to 2.2.4 and eventually 2.2.5.


Are you _sure_ it worked fine on 2.2.3? That version had Plupload 1.4.0 as upload library, and 2.2.5 has 1.4.1. Apart from some minor tweaks there's no real reason why it should've stopped working.

Besides, his hosting party is retarded. There's nothing against securing a server, but disabling features is stupid. Especially when they just tell their clients that it's disabled, without providing a solution or a workaround. By the same reasoning they should just take his website offline, because only then it will be truly safe from hackers. Sheesh.
Bob
Lead Developer
 
Posts: 1374
Joined: Tue Nov 20, 2007 11:16 pm

Re: PivotX 2.2.2 Image Upload does not work

Postby Logfather » Tue Mar 15, 2011 4:46 pm

Yes I know, they are crazy. I am sure it worked before because I used it myself.

I know that the cause IS that uploaded files are given the chmod of 0660. When I go to an image at http://www.example.nl/images/photo.jpg for example it gives me error 403 "you can't access blabla". When I chmod to 0664 it works fine.

I think this time the Pivot forum can't help and this guy has to find himself a new host. Thanks Harm & Bob trying to solve this!
Logfather
 
Posts: 163
Joined: Sun Jul 12, 2009 9:29 am
Location: Amsterdam

Re: PivotX 2.2.2 Image Upload does not work

Postby Mikeb » Mon Apr 04, 2011 11:06 pm

Hi Bob,
I think I'm having the same problem... it is at least very similar.

I am now using version 2.2.6 - updated from the latest stable release as I was having difficulties with that.

I have read through many posts and this comes closest to my issue, I have also totally wiped the site and started again...

On uploading (from anywhere) the image gets uploaded, but no one can do anything with it as it on gets "Owner read/write" (600 / 0600).
It seems, as I found from a reply from my host (below) that the file is NOT getting uploaded correctly to a temp directory, but directly into the destination and as such not getting the file permissions changed.

Here is my reply from the host:

Thank you for getting in touch, when files are uploaded in PHP they are moved to a temporary location and are set permissions '600', so that web users can not see your temporary files. Once the file has been created on the server, it should then be moved using the function called 'move_uploaded_file() ' to a location on the server, specified in the PHP code. This function (move_uploaded_file() ) also changes the permissions to '644'.

I have had a look through the 'fileupload.php' file in your web folder and it appears that you are not using these functions to handle uploaded files, this is probably why your files are not being created with the correct permissions. Unfortunately as we do not offer official code support, I would be unable to make changes to your scripts for you.

I would advise that you either use the functions mentioned above to upload files, or use the PHP function called 'chmod()' to alter the file permissions once uploaded.

Sorry I couldn't help further, please let me know if we can be of any further assistance.


I hope this helps you figure out the hassle for everyone.

If you would like to look at the server in detail, let me know, I'll pm a login...

Thanks in advance
Mike
User avatar
Mikeb
 
Posts: 16
Joined: Sun May 30, 2010 8:14 pm
Location: Wakefield, UK

Re: PivotX 2.2.2 Image Upload does not work

Postby hansfn » Tue Apr 05, 2011 6:57 am

I think it's a strange requirement (from your hoster) that all PHP code/programs must use move_uploaded_file. I'm not sure we are going to change this ... Anyway, we can test if your hoster is correct/try to fix your problem. In fileupload.php, replace

Code: Select all
    if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
        // Open temp file
        $out = fopen($targetDir . DIRECTORY_SEPARATOR . $fileName, $chunk == 0 ? "wb" : "ab");
        if ($out) {
            // Read binary input stream and append it to temp file
            $in = fopen($_FILES['file']['tmp_name'], "rb");

            if ($in) {
                while ($buff = fread($in, 4096))
                    fwrite($out, $buff);
            } else {
                Header('HTTP/1.0 500 Failed to open input stream');
                die('{"jsonrpc" : "2.0", "error" : {"code": 101, "message": "Failed to open input stream."}, "id" : "id"}');
            }

            fclose($out);
            unlink($_FILES['file']['tmp_name']);
        } else {
            Header('HTTP/1.0 500 Failed to open output stream');
            die('{"jsonrpc" : "2.0", "error" : {"code": 102, "message": "Failed to open output stream."}, "id" : "id"}');
        }
    } else {
        Header('HTTP/1.0 500 Failed to move uploaded file');
        die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
    }

with

Code: Select all
    // (This modified code doesn't support chunks.)
    if (isset($_FILES['file']['tmp_name'])) {
        if (!move_uploaded_file($_FILES['file']['tmp_name'], $targetDir . DIRECTORY_SEPARATOR . $fileName)) {
            Header('HTTP/1.0 500 Failed to move uploaded file');
            die('{"jsonrpc" : "2.0", "error" : {"code": 103, "message": "Failed to move uploaded file."}, "id" : "id"}');
        }
    }
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: PivotX 2.2.2 Image Upload does not work

Postby dubbelf » Tue Apr 05, 2011 12:13 pm

I think I got the same problem. At least, image upload does not work. The map is created, but remains empty.
When I change fileupload.php as you say, I get an error message (in the image name field of the 'Insert an image' box) which reads: unexpected end in fileupload.php
dubbelf
 
Posts: 4
Joined: Tue Apr 05, 2011 12:09 pm

Re: PivotX 2.2.2 Image Upload does not work

Postby hansfn » Tue Apr 05, 2011 12:46 pm

Then you probably made a typo when replacing code.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

Re: PivotX 2.2.2 Image Upload does not work

Postby dubbelf » Tue Apr 05, 2011 1:44 pm

You're right, I missed a bracket

However, now it says: upload error.
dubbelf
 
Posts: 4
Joined: Tue Apr 05, 2011 12:09 pm

Re: PivotX 2.2.2 Image Upload does not work

Postby Mikeb » Tue Apr 05, 2011 8:08 pm

Hi Hanfn;

Sorry it has taken so long to get back to you, long hard day at work...

I altered the code and seem to get the same error as dubbelf!!

If I upload in chrome, I get a progress bar but once it is filled up I get the "upload error" message in the upload dialog - the file is not uploaded either. In firefox I just get the "upload error" message.
The file was getting uploaded before the code change, it's just the permissions that were not getting changed.

I forgot to mention in my first post the phpinfo: http://rachel.millionairepalace.co.uk/phpinfo.php (PHP Version 5.3.6)
I have done many sites with pivotx on this server and only had one other issue (server dependent and fixed by yourselves) and would like to thank and praise you and the rest of the team for your hard work and for such a polished product.

Mike

P.S. Thought I'd also missed the last bracket, I hadn't definitely copied correctly!
User avatar
Mikeb
 
Posts: 16
Joined: Sun May 30, 2010 8:14 pm
Location: Wakefield, UK

Re: PivotX 2.2.2 Image Upload does not work

Postby hansfn » Tue Apr 05, 2011 8:25 pm

It could mean that move_uploaded_file doesn't work like your hoster claim - or it could be something else ... (The code change worked for me - I did test.) Currently, I don't have time to investigate further, but next week I might have some spare. Fixing/debugging this would require PivotX and FTP access.
hansfn
Developer
 
Posts: 3282
Joined: Sun Nov 25, 2007 7:48 pm
Location: Molde, Norway

PreviousNext

Return to 2.x Bugs

Who is online

Users browsing this forum: No registered users and 2 guests

cron