/    Sign up×
Community /Pin to ProfileBookmark

warning stat failed

I have a script which builds a pdf document and then inserts it into a directory with the chmod 777. We have gone into shell and changed all the document permissions to 777 as well to try to solve this problem and also changed the user from apache to the correct owner of the files.

I am still getting this error tho:

Warning: stat failed for (errno=2 – No such file or directory)

[code=php]
$this->attachment = ‘/home/httpd/virtualhosts/someurl.com/subdomains/development/public_html/admin/quotes/’.$attachment.’.pdf’;

if (file_exists($this->attachment))
{
$file = fopen($this->attachment,’rb’);
$data = fread($file,filesize($fileatt));
fclose($file);
}
[/code]

How can the file exist yet not be found?

thanks in advance

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@knowjauthorAug 07.2007 — This is what i get when i echo the full headers/message and error:
[code=php]Warning: stat failed for (errno=2 - No such file or directory) in /home/httpd/vhosts/url.com/subdomains/develop/httpdocs/somepath/includes/class_email.php on line 75

To:

From: blah
Cc:
Bcc: [email protected]

MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="==Multipart_Boundary_x939fa3625ffeace8efa916a26a24a2b7x"

quoteThis is a multi-part message in MIME format.

--==Multipart_Boundary_x939fa3625ffeace8efa916a26a24a2b7x
Content-Type:text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

quote


------------------------------------------------

Some signature blah blah blah

--==Multipart_Boundary_x939fa3625ffeace8efa916a26a24a2b7x
Content-Type: application/octet-stream;
name="0726.pdf"
Content-Transfer-Encoding: base64



--==Multipart_Boundary_x939fa3625ffeace8efa916a26a24a2b7x--
[/code]


[code=php]
class email extends paging
{
var $to;
var $toname;

var $cc;
var $bcc;

var $from;
var $fromname;

var $subject;

var $massage;
var $attachment;
var $file_name;

function email($to=NULL, $toname=NULL, $from=NULL, $fromname=NULL, $message=NULL, $subject=NULL, $cc=NULL, $bcc=NULL, $attachment=NULL)
{
$this->to = $to;
$this->toname = $toname;

$this->cc = $cc;
$this->bcc = $bcc;

$this->from = $from;
$this->fromname = $fromname;

$this->subject = $subject;

$this->message = $message;

$this->attachment = '/home/httpd/vhosts/url.com/subdomains/develop/httpdocs/somepath/quotes/'.$attachment.'.pdf';
$this->file_name = $attachment.'.pdf';
}

function email_client_attachment()
{
// multiple recipients
$to = $this->client_email;

// subject
$subject = $this->subject;

$signature = '


------------------------------------------------

signature to add onto email';

if (file_exists($this->attachment))
{

$fileatt_type = "application/octet-stream"; // File Type
$fileatt_name = $this->file_name; // Filename that will be used for the file as the attachment
// Read the file to be attached ('rb' = read binary)
$file = fopen($this->attachment,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);

// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

//Add the standard headers
$headers .= 'To: '.$this->toname.' <'.$this->to.'>'."rn";
$headers .= 'From: '.$this->fromname.' <'.$this->from.'>'."rn";
$headers .= 'Cc: '.$this->logged_email."rn";
$headers .= 'Bcc: [email protected]'."rn";

// Add the headers for a file attachment
$headers .= "nMIME-Version: 1.0n" .
"Content-Type: multipart/mixed;n" .
" boundary="{$mime_boundary}"";

// Add a multipart boundary above the plain message

// message
$this->message .= "This is a multi-part message in MIME format.nn" .
"--{$mime_boundary}n" .
"Content-Type:text/html; charset="iso-8859-1"n" .
"Content-Transfer-Encoding: 7bitnn" .
$this->message.' '.$signature . "nn";

// Base64 encode the file data
$data = chunk_split(base64_encode($data));

// Add file attachment to the message
$this->message .= "--{$mime_boundary}n" .
"Content-Type: {$fileatt_type};n" .
" name="{$fileatt_name}"n" .
//"Content-Disposition: attachment;n" .
//" filename="{$fileatt_name}"n" .
"Content-Transfer-Encoding: base64nn" .
$data . "nn" .
"--{$mime_boundary}--n";
$ok = @mail('', $this->subject, $this->message, $headers);
}
else
{
echo 'fail';
//$headers .= 'To: '.$this->toname.' <'.$this->to.'>'."rn";
//$headers .= 'From: '.$this->fromname.' <'.$this->from.'>'."rn";
//$headers .= 'Cc: '.$this->cc."rn";
//$headers .= 'Bcc: '.$this->bcc."rn";
//$this->message = $this->message.$signature;
}


echo '<pre>'.$headers.'</pre>';
echo '<pre>'.$this->message.'</pre>';


//Send the email

if ($ok)
{
echo '<div class="message">Message Sent!'.$this->attachment.' '.$this->message.'</div>'."nr";
}
else
{
echo '<div class="message">Message Not Sent!'.$data.' '.$this->message.'</div>'."nr";
}
echo '<pre>'.$data.'</pre>';
}
}
[/code]
×

Success!

Help @knowj spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...