Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8146419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:59:27+00:00 2026-06-06T13:59:27+00:00

I want to use the script below to add pdf files stored as blob

  • 0

I want to use the script below to add pdf files stored as blob data to a ZIP.

I get two errors that I do not understand

Warning: file_put_contents(ATPstatement201203.pdf)
[function.file-put-contents]: failed to open stream: Permission denied

and

Notice: ZipArchive::addFile() [ziparchive.addfile]: Empty string as
filename

I do not know what I am doing wrong?

$TP_Month  =''.$_POST["tp_year"].''.$_POST["tp_month"].'';
$TP_format =$TP_Month;

echo $_POST["ids"];

$zip = new ZipArchive;
$zip->open('file.zip', ZipArchive::CREATE);
foreach( explode( ',', $_POST["ids"]) as $Client_ID)
{
  $sql_qry="select *
            from   ca_client_statement
            where  client_id='".$Client_ID."' and trading_period_month like '".$TP_Month."'";
  $sql_err_no=sql_select($sql_qry,$sql_res,$sql_row_count,$sql_err,$sql_uerr);

  $row = mysql_fetch_assoc($sql_res);
  $file_content = $row['pdf_statement'];
  $file_name = ''.$Client_ID.'statement'.$TP_format.'.pdf';
  $file=file_put_contents($file_name, $file_content);
  $zip->addFile($file);
}
$zip->close();

header('Content-Type: application/zip');
header('Content-disposition: attachment; filename=filename.zip');
header('Content-Length: ' . filesize($zipfilename));
readfile($zipname);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T13:59:30+00:00Added an answer on June 6, 2026 at 1:59 pm

    “Permission denied” means the web server doesn’t have the permissions to write to the location you’re trying to save the file to. You’ll have to change the permissions to the directory that you’re trying to write to using chmod from the command line (if you’re on linux).

    As a proof of what is wrong, you can do chmod 777 /path/to/your/save/location, however it isn’t a good idea to keep the permissions that wide open, and you should dial it back to 644 or so.

    And you’re getting the “Empty string as filename” because file_get_contents() is failing (with the above error), and when it fails, it returns boolean false (as per the docs), which is (apparently) being interpreted as an empty string filename.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use a batch script to loop through folders and subfolders, and
I want to use the same ant script to do a build in either
I want to execute a script every 30mins, but i want to use it
I could use another pair of eyes. This script does what I want in
i want use some data from a website with web service. i have a
I have a transaction log file in CSV format that I want use to
Right below the start of the <body> tag, I want to include a script
I want to use 960 gs adaptive.js script which allows you to select different
I want to make ajax call to get data for results nodes. In my
Hi i installed the neocomplcache script and its great but i want to use

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.