I'm almost certain they are related to the temp directory's file permissions. Though I would like a second opinion on possibly finding another solution.. here goes -
The script im using works fine on my Windows machine using Apache. But the host i'm using to test it is running a Cobalt server.
The objective is to have the user fill out a form and then create a file containing that information. Along with the form is two attachments that are uploaded and put into an "uploads" folder.
This is the error message.
Warning: unable to create file _.txt because Permission denied in /home/sites/site2/web/m2moperations/uploadfile.php on line 31
Warning: fopen(".txt","w") - Permission denied in /home/sites/site2/web/m2moperations/uploadfile.php on line 33
Unable to write to .txt
<?php
//uploads direcroty
$udir = "uploads/";
//data file name
$filename = "$POST[FFirstName]$_POST[FLastName].txt";
//check for directory
if (is_dir("$udir")) {
upload( $filename, $udir );
} else {
//create directory
mkdir("$udir");
upload( $filename, $udir );
}
function upload( $filename, $udir ) {
//create file
touch("$filename");
//open file for writing
$fp = fopen($filename, "w") or die("Unable to write to $filename");
fwrite($fp, "$POST[FFirstName]\n");
fwrite($fp, "$POST[FLastName]\n");
fwrite($fp, "$POST[FEmailAddress]\n");
fwrite($fp, "$POST[SAddress]\n");
fwrite($fp, "$POST[FCity]\n");
fwrite($fp, "$POST[FState]\n");
fwrite($fp, "$POST[FZipCode]\n");
fwrite($fp, "$POST[FCountry]\n");
fwrite($fp, "$POST[FPhoneNumber1]\n");
fwrite($fp, "$POST[FPhoneType1]\n");
fwrite($fp, "$POST[FEmployerSearch]\n");
fwrite($fp, "$POST[FCareerFocus1]\n");
fwrite($fp, "$POST[FCareerFocus2]\n");
fwrite($fp, "$POST[FPositionType1]\n");
fwrite($fp, "$POST[FEducationLevel]\n");
fwrite($fp, "$POST[FSalaryMin]\n");
fwrite($fp, "$POST[FSalaryMax]\n");
fwrite($fp, "$POST[FTitle]\n");
fwrite($fp, "$POST[FCoverLetter]\n");
fwrite($fp, "$POST[FDescription]\n");
//close file
fclose($fp);
//upload files
foreach($_FILES as $file_name => $file_array) {
if (is_uploaded_file($file_array['tmp_name'])) {
move_uploaded_file($file_array['tmp_name'],
"$udir/$file_array[name]") or die ("Couldn't copy");
print "$file_array[name] uploaded successfully!<BR><BR>";
}
}
}