pdf file renamed in email - pdf

I am struggling with the file name of a PDF created on the fly (FPDF 1.82) using PHPMAILER (6.3.0) under PHP 5.6.17
$pdfdoc = $pdf->Output('pdf_doc.pdf', 'S');
$mail->addStringAttachment($pdfdoc, 'pdf_doc.pdf', 'base64', 'application/pdf');
Everything works fine only the attached PDF file is renamed .$path !
The file sent is a perfectly readable non corrupted pdf file.
$doc = $pdf->Output('pdf_doc.pdf', 'F'); downloads the file with the proper name !!!
The only clue would be in the error message :
Fatal error: Uncaught exception 'PHPMailer\PHPMailer\Exception' with
message 'Could not access file: ' in ....
PHPMailer\PHPMailer\PHPMailer->addAttachment('', 'pdf_doc.pdf')
meaning that the $doc is not recognised
Well, you know everything ...Any idea of what can go wrong with this pdf title ?
Many thanks

Related

"Get XML Data" step of pentaho is not able to read same xml file sometimes

I am using pentaho kettle tool for ETL job. In the job, one of the step(Get XML Data) is not able to read/parse xml file sometime. Sometime same XML file didn't throw any exception and sometime it threw. The list of errors are as given below -
1) Error on line 1 of document
file:///D:/softwares/pdi-ce-6.0.1.0-386/data-integration/UTF-8 : The
element type "Confidence" must be terminated by the matching end-tag
"".
2) org.dom4j.DocumentException: Error on line -1 of document :
Premature end of file. Nested exception: Premature end of file.
However, i don't find any issue in xml file. Could anyone help on this topic?
I didn't find the root cause but got the solution. The xml file which was being parsed by the step, was inside the zip file. Before parsing the xml file, a java step was unzipping the zip file. Instead of unzipping the zip file, i directly parsed the xml file inside the zip. That resolves the issue and no any error is reported again.

Error reading a .stp file with Assimp library

So I've been trying to read a .stp file with the latest assimp library.
The error I get is: "ERROR: Failed to load file: IFC: Unrecognized file schema: AUTOMOTIVE_DESIGN".
On the chance that my file was corrupted, I took a wavefront file I had and exported it to '.stp' using 'assimp' and I get the same error as above when I try to read the file back with assimp.
Would anyone have a clue about the file schema error with assimp or why assimp will not read a file it created?
At the moment Asset-Importer-Lib does only support the IFC-2.3-Format. So when the file format does not contain the following tag:
FILE_SCHEMA( ( 'IFC2X3' ) );
the import will fail at the moment. SO you can try to change this schema entr.
It would be nice to get your model for a deeper investigation ( just use our github-page: https://github.com/assimp )

PHPMailer giving rtf file .txt extension

First time using PHPMailer within Yii and i've got the files to attach fine in email form using .doc, .rtf and .txt. I then tried to add the optional name to the file rather than the uploaded name and my rtf file was sent as a .txt file. Not sure why? Wondered if anyone could point me int he right direction.
$mail = new YiiMailer();
//$mail->clearLayout();//if layout is already set in config
$mail->setFrom('email#example.com', 'Me!');
$mail->setTo(Yii::app()->params['adminEmail']);
$mail->setSubject('Mail subject');
$mail->setBody('Simple message');
$mail->AddAttachment($dest . '/' . $file->tmp_name . '.' .$file->extension, $file->name);
Thanks in advance
Jonnny
Seems that if I pass all the arguments to the AddAttachment() it sends the RTF as a .doc file.
$mail->AddAttachment($dest . '/' . $file->tmp_name . '.' .$file->extension, $file->name, 'base64', $file->mime_type);
Jonnny

Error trying rename a file

Hi community!
I have an application in VB.Net, in the user's computer is located in program files.
The users run always the program as an Administrators.
But in some cases; when the program try to rename a file in the program files the program throws the following exception:
The given path's format is not supported.
SOURCE = System.Security.Util.StringExpressionSet.CanonicalizePath
Also, happens when I try to copy a file.
The application does the rename or copy automatically and it's the same name for all the users
Example:
Rename(vOld, vNew)
FileCopy(vOld, vNew)
This exception only happen in Win7.
Somebody have an idea what is the reason to some users appear this exception?
This will happen when the user provides an invalid file name, for example one that includes colons.
You should validate that the user-entered file name does not contain any of the values in System.IO.Path.GetInvalidPathChars.
All it's my fault!
-_-'
I'm trying to rename this path:
C:\_MyFile.xlsx
To:
C:\MyFile.xlsx
In my computer all works fine because I have the both files (The users only has the file with the underscore).
When the program try to validate it try to rename the file "_C:\MyFile.xlsx" to "C:\MyFile.xlsx"
The exception don't give much information about my error...

Create dummy index.html inside a new MKDR directory

I know this may be a silly question but i cant seem to find just a simple answer.
I have a php script that makes a directory for me when the user starts a new entry.
That directory holds photos for their gallery.
What i would like to do is also create One index.html file inside that new directory with a few lines of html code in it.
How do i do this?
Im guessing that the file would be made like so:
mkdir('users/'.$id.'/index.html',0755);
But how do i add the html into that index.html file?
Or do i have one file on the server and copy it over into there during the MKDIR process?
Anyways a really simple answer would be best as i am very slow in this learning thing.
Thank you
John
New edits.....
<?php
$id = 812;
mkdir('users/'.$id,0755);
chmod('users/'.$id,0777);
$fh = fopen( "users/".$id, "w+" ) or die( "Couldn't open file" );
fwrite( $fh, "<html><head /><body><h1>It Works!</h1></html>" );
fclose( $fh );
?>
Its giving me this error?
Warning: fopen(users/812) [function.fopen]: failed to open stream: Permission denied in stackoverflowtest1.php on line 9
Couldn't open file
Any ideas? I am on a wamp windows 7 server and not using ftp to edit files but just the www wamp explorer foler.
I'm not sure which language you are using so you'll either need to update your question or forgive the lack of concrete code. mkdir is for generating directories and not flat files. To do that you'll need to open then the file handle then print the HTML lines to that handle and then close it.
A file handle is a pointer to a file. It allows you to manipulate the data in that file ( i.e. read or write it ).
example code:
$fh = fopen( "path/to/file/index.html", "w+" ) or die( "Couldn't open file" );
fwrite( $fh, "<html><head /><body><h1>It Works!</h1></html>" );
fclose( $fh );
The path to the file needs a file name as a target, sorry that wasn't clear.