Support

Account

Home Forums Front-end Issues Front End Uploading

Solving

Front End Uploading

  • hello,

    for some reason the upload files have stopped working. Ive been using a file field to allow users to attach a file to the post. Which has been working fine for a while now, but for some unknown reason its stopped working.

    ive checked the error log and i get this error message;

    [30-Jul-2015 20:50:20 UTC] PHP Warning: filesize(): stat failed for /tmp/phpl45HTt in /home/[removed for security reasons]/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 3130
    [30-Jul-2015 20:50:20 UTC] PHP Warning: getimagesize(/tmp/phpl45HTt): failed to open stream: No such file or directory in /home/[removed for security reasons]/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 3134

    Is this a problem at my host or plugin ? Ive set the file size in the options field and left it blank, both result in the error.

  • What version of ACF are you using?
    Is this with a front end form or in the admin?
    Have you tried uploading images for the field?

    turn on WP error reporting and see what kind of errors you get. Add to wp-config.php:

    
    define('WP_DEBUG', false);
    define('WP_DEBUG_DISPLAY', false);
    

    The two errors you’re listing are after the upload so there is some reason that the file is not being uploaded. for example, PHP has not save the uploaded file to the temp folder.

    Do you have a limit to the number of files or amount of space you can use on the host? There are a whole host of reason that could prevent a file from being uploaded.

  • Hello,

    I apologize for the late reply. I have the latest version of ACF Pro. I have the latest version of WordPress.

    The Image field works, because im using it to set the feature image. The problem i have is when i try to upload a .pdo type file using the file upload field.

    Ive enabled the debugging like you say but i dont seem to see any errors when i try to upload a .pdo type file.

    Ive been in contact with my service provider and they say nothing has changed their end and as i say, its worked before

  • After a quick look around it does not appear that WP supports .pdo files. I’m thinking that might be where you’re running into a problem. Honestly I don’t know if WP can display .pdo files but in order to upload them you’ll need to alter the PW allowed field times. For more information https://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes

  • Sorry i should’ve pointed out i’ve added it to the allowed file types in my theme functions.

    I’ve narrowed it down (somewhat…) since adding the file type to the allowed list, i’ve noticed that if the file has spaces in it, so “file name” it doesn’t get uploaded. Therefore it has to be “file-name” or “file_name” and it uploads it.

    HOWEVER it’s still not being attached to the post, BUT when i var_dump the array i get this:

    [“filename”]=>
    string(22) “does-it-need-no-spaces”

    But the url is blank
    [“url”]=>
    bool(false)

    EDIT: Actually, the filename is also being set the same as the post title.

    My Upload Page code http://pastebin.com/TBiSU4WR
    My Form Export http://pastebin.com/ZdKMwDtK

  • I’m pretty sure it does not have to do with spaces.

    And this is only with .pdo files, other images and files work fine?

    What happens when you try to upload a .pdo file to the media library in the admin, does this work?

    I’ve been looking and I can’t really seem to find any information about .pdo files in WP.

    At this point I’d just be guessing, but it appears that there is something interfering with the upload. My next step would be to start deactivating plugins, or to see what happens on a test installation with the default theme and only ACF installed, and of course the filter to add the mime type.

  • I’ve tried disabling all plugins (Over then the plugins needed) and it still isnt working.

    The tmp folder has 755 permission so im able to write to it.

    I’ve just tried it on a different theme like you suggested and it still doing the same. It might be a bug with the actual API code. Its just baffling as to why its suddenly stopped working.

  • So, it was at one time allowing you to upload .pdo files?

    If so I missed that.

    Did the time it stopped working have anything to do with the recent WP 4.2.3 update?

  • It doesnt even allow for the image field anymore

    [01-Aug-2015 01:43:01 UTC] PHP Warning: filesize(): stat failed for /tmp/php9JTRVT in /home/[removed for security reasons]/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 3130

    [01-Aug-2015 01:43:01 UTC] PHP Warning: getimagesize(/tmp/php9JTRVT): failed to open stream: No such file or directory in /home/[removed for security reasons]/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 3134

    [01-Aug-2015 01:43:01 UTC] PHP Warning: filesize(): stat failed for /tmp/phpCbyNkr in /home/[removed for security reasons]/wp-content/plugins/advanced-custom-fields-pro/api/api-helpers.php on line 3130

    Yes, its been working fine for a good few months and suddenly stopped working a few days ago, but i cant remember if it was before or after the update. i might try downgrading my wordpress and see if that solves the problem.

    Thank you for trying to help, i appreciate it.

  • A few days ago WP pushed an update. This update has been known to break a lot of plugins shortcodes incorrectly. When you said:

    I’ve tried disabling all plugins (Over then the plugins needed)

    The only way to be sure is to deactivate all other plugins. They should not be needed in during the file upload process.

    I’d like to test on my test server, but I don’t know how large .pdo files are, I’ve never dealt with them. If there is such a thing as a “small” .pdo file, can you try uploading it here so that I have something to test the upload with?

  • Cant attach due to security reasons, ill upload it to a file host

    http://thomasrenshaw.com/public/Arkham%20Knight%20Helmet.pdo

  • What is the mime type of a .pdo file, can’t find it. Can you post the filter you’re using to add this to WordPress

  • I just use this in my themes function

    function ApproveMime($mime_types){
    
        $mime_types['pdo'] = 'application/octet-stream';
        return $mime_types;
    
    }
    
    add_filter('upload_mimes', 'ApproveMime', 1, 1);
  • Was past my bed time last night. I just created a file field on the front end of a test site and I added your filter to allow uploading of .pdo files. The field and the upload worked perfectly. This is a site that is the current version of WP and the only plugin enabled on the site is ACF.

    The last thing that I want to be sure of is that this is a “File” field as you mentioned in the OP. The errors seem to indicate that it’s an image field or for some reason that something is trying to treat the .pdo as an image file. Unless you have some other plugin that recognizes .pdo as image files, .pdo files are not image files.

    Beyond that, there must be something going on with one of the your other plugins. You will need to figure out which one is causing the conflict.

  • Hey John,

    I apologize for being so late in replying, I’ve been busy at work and haven’t had time to.

    The image error appears since i added a image field to test if it would allow me to upload one.

    Since i added the function i posted for you the .pdo files are uploading to my host, however the problem i have now is it isn’t being attached to my post. And if i go to the media library they say “(Unattached)” in the column

  • I’m seeing this as well, when I attempt to upload a .pdo file to an image field. But when uploaded to a file field they are attached correctly. I think this all boils down to WP not considering .pdo files as images.

  • This reply has been marked as private.
  • This reply has been marked as private.
  • As I said, .pdo files are not recognized by WP as an image file. More than likely this is causing all the errors that you’re seeing. This is not an error or a bug in ACF as far as I can tell.

  • Im not uploading the pdo file type in the image field? im using the file field.

  • I’ve tried uploading the file you gave me and I’m not seeing the errors you are seeing.

    If you haven’t already you might want to consider opening a new support ticket http://support.advancedcustomfields.com/new-ticket/. They may be able to help you with this more than other users.

  • Hi @renshaw

    I’m going to look into this shortly, but for now, an easy fix is to modify the plugin files and add @ before the filesize function. That will prevent errors being returned.

  • Thats stopped the error from showing but sadly still isnt working. Do you have an ETA on when your’ll get to look at this its holding up my site a lot and i really need this fixing :/

  • @renshaw Are you filtering pre_save_post? I encountered the same issue and it was due to me calling do_action( 'acf/save_post' , $post_id ); within the pre_save_post filter – doh!

  • I think i am,

    
    function PreSaveForm( $post_id ) {
    
        if ( ! ( is_user_logged_in() || current_user_can('publish_posts') ) ) {
            return;
          }
    
        // check if this is to be a new post
        if( $post_id != 'new' ) {
            return $post_id;
        }
    
        // Create a new post
        $post = array(
            'post_type'     => 'file', // Your post type ( post, page, custom post type )
            'post_status'   => 'publish', // (publish, draft, private, etc.)
            'post_title'    => wp_strip_all_tags($_POST['acf']['field_55ba5b162db22']), // Post Title ACF field key
        );
    
        // insert the post
        $post_id = wp_insert_post( $post );
        // Save the fields to the post
        do_action( 'acf/save_post' , $post_id );
    
        return $post_id;
    }
    add_filter('acf/pre_save_post' , 'PreSaveForm' );
    

    How would i fix this ?

Viewing 25 posts - 1 through 25 (of 25 total)

The topic ‘Front End Uploading’ is closed to new replies.