I'm doing a "job application" from the book PHP programing and I have an error. Here's the story:
You fill out the application, and you also given a chance to attach/upload your "resume" with your "job application" submission. Well, everything works fine when you have an application, it places the resume and a .txt and submission feild submissions into it's own text.
The scrip is made that you don't need to attach your "resume," however, when I don't attach it it says:
Warning: Unable to open 'none' for reading: No such file or directory in .../jobapp_action.php on line 79
Error saving resume.
However, your application will still be processed.
Note that "Error saving resume..." is suppose to show up when a resume isn't sumitted but the "Warning" shouldn't.
this is the portion of the code:
echo (NL . NL);
If ($userfile) {
if (copy($userfile, "./temp/$applicant")) { \\ line # 79
echo("<B>Resume received: thank you!</B>");
} else {
echo("<B>Error saving resume.</B>" .
"However, your application will still be processed.");
}
}
You can suppress the error message from the copy() function by adding an @ to the beginning of the line, as follows:
echo (NL . NL);
If ($userfile) {
if (@copy($userfile, "./temp/$applicant")) { \\ line # 79
echo("<B>Resume received: thank you!</B>");
} else {
echo("<B>Error saving resume.</B>" .
"However, your application will still be processed.");
}
}
copy() will still return false when no resume is submitted so that your custom error message is displayed, but the PHP error message will no longer appear.
Err.. Surely Kevin a better way would be to not suppress the error message and deal with the condition rather than have code with what is technically a bug in it?
Change
<BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>If ($userfile) {[/code]
to
<BLOCKQUOTE><font size="1" face="Verdana, Arial">code/font><HR><pre>If ($userfile != 'none') {[/code]
and it will work, PHP sets the file upload variable to none if their is no file to be uploaded.
------------------
Karl Austin KDA Web Services
"Everyone has a photographic memory. Some just don't have film."
Indeed I considered that, but Alex's original post mentioned that he wanted the message to appear when no resume was submitted. The code does seem to be intended to work the way you describe, however.
Although that code worked, I still had to add the "@" symbol in my final note for those who didn't submit a resume. Because what the program does is, if it has an attached resume, it takes it and downloads it to a temporary folder, and then renames it to "resume.txt" after a final submission is made it is moved to the final folder.
However, when it didn't have the resume, it could create "resume.txt" or delte it... so I've gotten errors, however, adding @ character helped.
Other than that "If ($userfile != 'none') {" worked well.
Bookmarks