FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » FudAPI Examples
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: FudAPI Examples [message #36091 is a reply to message #35953] Sat, 03 March 2007 20:18 Go to previous messageGo to previous message
dardhal is currently offline  dardhal   Spain
Messages: 9
Registered: November 2006
Location: Spain
Karma:
Junior Member
Ilia wrote on Fri, 23 February 2007 02:42

You need permissions to be 777 not 755


Sorry for the delay. Even after chmod'ing both tmp/ and files/ directories to 777, the script doesn't work with the same error "unable to move uploaded file". From the command line and running the PHP script as root.

I have had some free time to investigate, and I think I have found the place where it fails. function _fud_message_post calls attach_add, and inside this function safe_attachment_copy gets called, both are implemented in include/theme/default/attach.inc

Inside function safe_attachment_copy there is this little piece of code:

<?php
if (!$ext && !move_uploaded_file($source$loc)) {
                
error_dialog('unable to move uploaded file''From: '.$source.' To: '.$loc'ATCH');
        } else if (
$ext && !copy($source$loc)) {
                
error_dialog('unable to handle file attachment''From: '.$source.' To: '.$loc'ATCH');
        }
?>


And as the error message is an "unable to move uploaded file", and $ext contains zero from the caller, it seems PHP's move_uploaded_file is failing. From the PHP documentation:

Quote:

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

See also is_uploaded_file(), and the section Handling file uploads for a simple usage example.



So I have inserted a test just before the move_uploaded_file call, just to see if from PHP point of view the attachment was uploaded or not:
<?php
if ( is_uploaded_file($source) ) {
                
error_dialog('The file WAS uploaded''OK');
        }
        else {
                
error_dialog('The file was NOT uploaded','KO');
        }
?>


And I get, as expected, the following error:
index.php?t=getfile&id=2815&private=0

So it seems the fix is to make PHP believe the attachment was uploaded, even if it was not. Don't know if this is possible, and if it requires modification of my crappy PHP script, some kind of FUDapi initialization, etc.
  • Attachment: error.jpg
    (Size: 9.82KB, Downloaded 1681 times)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Deleting Moderation Queue
Next Topic: integration with a cms (the user database) possible?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 05:50:08 GMT 2024

Total time taken to generate the page: 0.03343 seconds