Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filename cannot be empty issue in print from mac machine #362

Closed
anavgire4 opened this issue May 17, 2017 · 3 comments
Closed

Filename cannot be empty issue in print from mac machine #362

anavgire4 opened this issue May 17, 2017 · 3 comments
Labels
Milestone

Comments

@anavgire4
Copy link

anavgire4 commented May 17, 2017

<?php
use Mike42\Escpos\Printer;
use Mike42\Escpos\PrintConnectors\CupsPrintConnector;
try {
    $connector = new CupsPrintConnector("EPSON_TM-T20");

    $printer = new Printer($connector);
    $printer -> text("Hello World!\n");
    $printer -> cut();
    $printer -> close();
} catch (Exception $e) {
    echo "Couldn't print to this printer: " . $e -> getMessage() . "\n";
}
?>

when i run above code on linux PC it's working fine but in mac it gives below error.
i think it might be an permission error.
please help me.

file_put_contents(): Filename cannot be empty

@anavgire4 anavgire4 changed the title Filename cannot be empty issue in print from mac machine MAC Filename cannot be empty issue in print from mac machine May 17, 2017
@mike42 mike42 added the bug label May 17, 2017
@mike42
Copy link
Owner

mike42 commented May 17, 2017

The usage of file_put_contents in CupsPrintConnector is-

// Build command to work on data
$tmpfname = tempnam(sys_get_temp_dir(), 'print-');
file_put_contents($tmpfname, $data);

Can you share your PHP version so that we can try to replicate? I don't have access to a web stack on Mac, but this method for creating temp files is the likely culprit.

@anavgire4
Copy link
Author

Thanks for such an early response.
We have used PHP 5.6.30 Version.

@mike42
Copy link
Owner

mike42 commented Jun 3, 2017

It appears to be a permissions issue- There are some common stacks that are setting up PHP without a write-able temp space, and a web search turns up plenty of people who have seen it. You can echo sys_get_temp_dir(); to find out which directory to adjust permissions on.

It is a bug that we don't return an error here that indicates temp files cannot be created, so I'll leave this open until that has been patched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants