class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
Here's the code. I don't see any log anywhere on the server.
// ---------- SIMPLE UPLOAD ----------
$name_body="Closing_".$account_id;
// we create an instance of the class, giving as argument the PHP object
// corresponding to the file field from the form
// All the uploads are accessible from the PHP object $_FILES
$handle = new Upload($_FILES['my_field']);
$handle->file_new_name_body = $name_body;
$handle->file_new_name_ext = 'pdf';
$handle->allowed = array('application/pdf');
// then we check if the file has been uploaded properly
// in its *temporary* location in the server (often, it is /tmp)
if ($handle->uploaded) {
// yes, the file is on the server
// now, we start the upload 'process'. That is, to copy the uploaded file
// from its temporary location to the wanted location
// It could be something like $handle->Process('/home/www/my_uploads/');
$handle->Process('./efiles/');
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
echo ' File uploaded with success';
echo ' ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB';
echo ' Link to the archive file just uploaded: file_dst_name';
} else {
// one error occured
echo ' file not uploaded to the wanted location';
echo ' Error: ' . $handle->error . '';
}
// we copy the file a second time
$handle->Process('./efiles/');
// we check if everything went OK
if ($handle->processed) {
// everything was fine !
//echo ' File uploaded with success';
//echo '' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB';
//echo ' Link to the actual file just uploaded: file_dst_name';
} else {
// one error occured
echo ' file not uploaded to the wanted location';
echo ' Error: ' . $handle->error . '';
}
// we delete the temporary files
$handle-> Clean();
} else {
// if we're here, the upload file failed for some reasons
// i.e. the server didn't receive the file
echo ' file not uploaded on the server';
echo ' Error: ' . $handle->error . '';
}//end else
// ---------- SIMPLE UPLOAD ---------- $name_body="Closing_".$account_id; // we create an instance of the class, giving as argument the PHP object // corresponding to the file field from the form // All the uploads are accessible from the PHP object $_FILES $handle = new Upload($_FILES['my_field']); $handle->file_new_name_body = $name_body; $handle->file_new_name_ext = 'pdf'; $handle->allowed = array('application/pdf'); // then we check if the file has been uploaded properly // in its *temporary* location in the server (often, it is /tmp) if ($handle->uploaded) { // yes, the file is on the server // now, we start the upload 'process'. That is, to copy the uploaded file // from its temporary location to the wanted location // It could be something like $handle->Process('/home/www/my_uploads/'); $handle->Process('./efiles/'); // we check if everything went OK if ($handle->processed) { // everything was fine ! echo ' File uploaded with success'; echo ' ' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB'; echo ' Link to the archive file just uploaded: file_dst_name'; } else { // one error occured echo ' file not uploaded to the wanted location'; echo ' Error: ' . $handle->error . ''; } // we copy the file a second time $handle->Process('./efiles/'); // we check if everything went OK if ($handle->processed) { // everything was fine ! //echo ' File uploaded with success'; //echo '' . round(filesize($handle->file_dst_pathname)/256)/4 . 'KB'; //echo ' Link to the actual file just uploaded: file_dst_name'; } else { // one error occured echo ' file not uploaded to the wanted location'; echo ' Error: ' . $handle->error . ''; } // we delete the temporary files $handle-> Clean(); } else { // if we're here, the upload file failed for some reasons // i.e. the server didn't receive the file echo ' file not uploaded on the server'; echo ' Error: ' . $handle->error . ''; }//end elseEvery time you call process(), you reset all parameters, so you can start from scratch to do something else with the file.
As for the log, simply output $handle->log after calling $handle->process().