• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Download Monitor & Manager Plugin

Simple Download Monitor & Manager for WordPress

  • Home
  • Documentation
  • Addons/Extensions
  • Login
    • Sign In
    • Edit Profile
    • My Downloads
  • Support
    • Tutorials
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration
  • Contact Us
You are here: Home / Topics / Squeeze Form – Downloading PDF result of Zero Bytes

[Resolved] Squeeze Form – Downloading PDF result of Zero Bytes

· ·

WordPress Download Monitor Plugin › Forums › Download Monitor Plugin Forum › Squeeze Form – Downloading PDF result of Zero Bytes

  • This topic has 8 replies, 2 voices, and was last updated 6 years, 1 month ago by ohwowmarketing.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • November 17, 2018 at 11:11 pm #849
    ohwowmarketing
    Participant

    I saw one of the topic here, but still give it a try. At first we were excited. But after the plugin was deploy to the live site, customers who tried to download the PDF ends with Zero Bytes.

    I tried to debug but no luck.
    I tried also to follow your suggestion about PHP Dispatch and toggle the check box for luck, still no works.

    I tried to install new fresh wordpress on my Mamp and install all your plugins, and guess what… still Zero bytes for the pdf file.

    Have you tried to check it lately guys if this still working? I mean, paying you almost $30 seems not worth for this plugin…

    November 21, 2018 at 1:11 am #850
    admin
    Keymaster

    Let me look into this. Are you using the secure downloads addon or just the main plugin? If you are using the secure download addon then are you using the dropbox option or just uploading the PDF file directly to your site?

    Can you share a link to the page where I can go and inspect the download button?

    November 21, 2018 at 3:14 am #851
    ohwowmarketing
    Participant

    Please watch this video i made… drive.google.com/open?id=1v3wtWJqMNVDRtCfGtxJnsHQ4ASpcLfj2

    Regarding page, I will create one for you guys.

    November 22, 2018 at 1:19 am #852
    admin
    Keymaster

    The sample page you showed looks very strange. It doesn’t have any header or footer. This plugin outputs some JavaScript code in the header. If the header is not loaded then it may not work correctly. Can you use a standard default WordPress theme (some like the twenty seventeen theme from wordpress) then use the shortcode on a page and see if you see the same behavior?

    November 22, 2018 at 5:27 am #853
    ohwowmarketing
    Participant

    As your suggestion, please watch the video. drive.google.com/open?id=1VBzlkoUtNUASF9mSIHmr5Pz-83fVD_rK

    Actually, my theme does heave header and footer. Since it was custom theme (and fresh installed) made by me to my client, it was more optimized than the usual.

    November 22, 2018 at 5:48 am #855
    admin
    Keymaster

    Thank you. Your setup looks fine to me. PHP must be failing to dispatch the correct header on this site for some reason. I will take a look inside your site. Please use the contact form on the site to send me access to the site (if possible). It should help me troubleshoot this.

    April 12, 2019 at 3:50 am #1073
    ohwowmarketing
    Participant

    Hello.

    It’s been 4 and half months after I open this thread. My bad I didn’t provide yet any access to the author. However, it is bad as well that I didn’t see if they’ve manage to check this error/issue.

    Anyway, upon debugging “in my case” today April 12, readfile() is failing to give a 200 ok code to the header in-which resulting http/1.1 403 forbidden to the attached PDF file.

    `
    Warning: readfile(http://localhost:8888/wp-content/uploads/2019/01/Brochure.pdf): failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /Users/mac/Sites/sandbox/wp-content/plugins/sdm-squeeze-form/sdm-sf-shortcodes.php on line 281
    `

    Base on my findings, readfile() throwing 403 to the pdf attachment which ending-up zero-byte. I tried to create small code inside the sdm-sf-shortcodes.php

    `
    $parsed = parse_url( get_post_meta($postid, ‘sdm_upload’, true) );
    $url = dirname( $parsed [ ‘path’ ] ) . ‘/’ . rawurlencode( basename( $parsed[ ‘path’ ] ) );

    $filePath = ABSPATH . substr($url, 1);
    `

    then I rewrite the readfile( $file ) var into readfile( $filePath );

    Overall, I am still open for some comments if they’ve manage to fix this issue. Else, i will mark this as resolved, if I can prove that the code I am using is the solution to this case.

    Regards,

    April 12, 2019 at 5:23 am #1075
    admin
    Keymaster

    This one is a site specific issue. If the code that you are using now is working then that’s totally fine.

    April 17, 2019 at 10:44 am #1077
    ohwowmarketing
    Participant

    ok, so this is the final code that is completely working.

    
    $parsed = parse_url( get_post_meta($postid, 'sdm_upload', true) );
    $url    = dirname( $parsed [ 'path' ] ) . '/' . rawurlencode( basename( $parsed[ 'path' ] ) );
    
    // Combine the absolute path and the attachment url
    $filePath = ABSPATH . substr($url, 1);
    
    // Get the attachment file-size
    $size = filesize($filePath);
    
    // Temporary disable due to error
    // $headers = get_headers($file, 1);
    // $fsize = $headers['Content-Length'];
    

    here’s the code will look like after the provision codes.

    
    header('Content-Length: ' . $size);
    readfile( $filePath );
    

    Hope this will help others.

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Log In

Primary Sidebar

Featured Addons

  • Squeeze Form Addon
  • Hidden Downloads Addon
  • Amazon S3 Integration

Support Links

  • Support Forum

Search

Featured Plugin

WP Express Checkout Plugin

Start managing and tracking your file downloads with the simple download monitor plugin. Download Now

Copyright © 2025 | Simple Download Monitor | A member of the Tips and Tricks HQ family.