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 5 years, 7 months ago by ohwowmarketing.
-
AuthorPosts
-
November 17, 2018 at 11:11 pm #849ohwowmarketingParticipant
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 #850adminKeymasterLet 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 #851ohwowmarketingParticipantPlease 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 #852adminKeymasterThe 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 #853ohwowmarketingParticipantAs 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 #855adminKeymasterThank 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 #1073ohwowmarketingParticipantHello.
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 a200 ok
code to the header in-which resultinghttp/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 thesdm-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 #1075adminKeymasterThis 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 #1077ohwowmarketingParticipantok, 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.
-
AuthorPosts
- You must be logged in to reply to this topic.