RedJumpsuit

jobberBase custom development and support

 

Code School

Send Photo on Apply Now

i have seen this request come up in the jobberBase forum here and there, so today i had the time to put together a how-to which will allow the applicants to send a photo of themselves when they send their resume on the job they are applying to.

so here it goes…

1) On /_includes/translations.ini, add under [apply]

photo_label = "Photo"
photo_error = "Photo size exceeds limit."
photo_info = "Accepts only *.jpg, *.gif and *.png"

2) /_templates/default/job-details.tpl, under this block:

<tr>
	<td valign="top"><label for="apply_cv">{$translations.apply.cv_label}:</label></td>
	<td>
		<input type="file" name="apply_cv" id="apply_cv" />
		<span class="validation-error">{if $smarty.session.apply_errors.apply_cv}<img src="{$BASE_URL}_templates/{$THEME}/img/icon-delete.png" alt="" title="{$smarty.session.apply_errors.apply_cv}" />{/if}</span>	
		<div class="suggestion">{$translations.apply.cv_info}</div>
	</td>
</tr>

add this block:

<tr>
	<td valign="top"><label for="apply_photo">{$translations.apply.photo_label}:</label></td>
	<td>
		<input type="file" name="apply_photo" id="apply_photo" />
		<span class="validation-error">{if $smarty.session.apply_errors.apply_photo}<img src="{$BASE_URL}_templates/{$THEME}/img/icon-delete.png" alt="" title="{$smarty.session.apply_errors.apply_photo}" />{/if}</span>	
		<div class="suggestion">{$translations.apply.photo_info}</div>
	</td>
</tr>

3) on page_apply.php, under this block:

if ($_FILES['apply_cv'] && $_FILES['apply_cv']['size'] >= MAX_CV_SIZE)
	{
		$errors['apply_cv'] = $translations['apply']['cv_error'];
	}

add this block:

if ($_FILES['apply_photo']['name'] != "" && $_FILES['apply_photo']['size'] >= MAX_CV_SIZE)
	{
		$errors['apply_photo'] = $translations['apply']['photo_error'];
	}
if ($_FILES['apply_photo']['name'] != "" && (($_FILES['apply_photo']['type'] != "image/gif") AND ($_FILES['apply_photo']['type'] != "image/jpeg") AND ($_FILES['apply_photo']['type'] != "image/png")))
	{
		$errors['apply_photo'] = $translations['apply']['photo_error'];
	}

next, under this block:

$filename = time() . '_' . $_FILES['apply_cv']['name'];
if (move_uploaded_file($_FILES['apply_cv']['tmp_name'], FILE_UPLOAD_DIR . $filename))
{
	$attachment = $filename;
}
else
{
	$attachment = '';
}

add this block:

$phfilename = time() . '_' . $_FILES['apply_photo']['name'];
if (move_uploaded_file($_FILES['apply_photo']['tmp_name'], FILE_UPLOAD_DIR . $phfilename))
{
	$phattachment = $phfilename;
}
else
{
	$phattachment = '';
}

after that, find this block:

$data = array('apply_email' => $apply_email,
		'apply_name' => $apply_name,
		'apply_msg' => strip_tags($apply_msg),
		'company_email' => $j->mPosterEmail,
		'company_name' => $j->mCompany,
		'job_title' => $j->mTitle,
		'attachment_path' => APP_PATH . FILE_UPLOAD_DIR . $attachment,
		'attachment_filename' => $attachment,
		'job_id' => $job_id);

and update with this block:

$data = array('apply_email' => $apply_email,
		'apply_name' => $apply_name,
		'apply_msg' => strip_tags($apply_msg),
		'company_email' => $j->mPosterEmail,
		'company_name' => $j->mCompany,
		'job_title' => $j->mTitle,
		'attachment_path' => APP_PATH . FILE_UPLOAD_DIR . $attachment,
		'attachment_filename' => $attachment,
		'phattachment_path' => APP_PATH . FILE_UPLOAD_DIR . $phattachment,
		'phattachment_filename' => $phattachment,
		'job_id' => $job_id);

lastly on that same file, find this block:

// delete uploaded file (cleanup)
if ($attachment != '')
{
	unlink(APP_PATH . FILE_UPLOAD_DIR . $attachment);
}

add this block under:

// delete uploaded photo (cleanup)
if ($phattachment != '')
{
	unlink(APP_PATH . FILE_UPLOAD_DIR . $phattachment);
}

4) open up /_includes/class.Postman.php and look for this function:

public function MailApplyOnline()
{
...
}

inside this function, look for this block:

if ($data['attachment_filename'] != '')
{
    $mailer->AddAttachment($data['attachment_path'], $data['attachment_filename']);
}

and add this below it:

if ($data['phattachment_filename'] != '')
{
    $mailer->AddAttachment($data['phattachment_path'], $data['phattachment_filename']);
}

just a note that i wrote this on top of my head (from what i remember i did for several other projects i did before) without testing/running the code, so if you come across any bugs, please let me know and if you found a fix, kindly share them here :)

Tagged as: , , , , ,

7 Comments

Code School

  1. Thanks
    Im working on a job board for actors so this helped a lot
    =)

  2. Thanks for this wonderfull hack. Erverything is working fine…excerpt in IE.
    IE standard gives me an error when uploading a photo.

    What should I do?

  3. i done all as instructed but, something is wrong in the url
    http://www.mydomain.com/apply-online it shows this page and a white screen nothing showing. when i click back i see the application count on the job description page. also the image is in my uploads directory, where is the mistake. also your shared codes

    // delete uploaded photo (cleanup)
    if ($phattachment != ”)
    {
    unlink(APP_PATH . FILE_UPLOAD_DIR . $phattachment);

    the above mine is called $filename instead of $phattachment

    need urgent help.

    thanks

  4. Hey, cool hack,

    I was trying to implement a similar photo uploading function in the post new job page. For example to include a company logo. But somehow I keep getting this undefined index error. I don’t understand because defined the variable ‘apply_photo’ has been in publish-write.tpl. Just like in the instructions above.

    Notice: Undefined index: apply_photo in C:\xampplite\htdocs\www\jobberbase\public\page_write.php on line 113

    Notice: Undefined index: apply_photo in C:\xampplite\htdocs\www\jobberbase\public\page_write.php on line 135

    Notice: Undefined index: apply_photo in C:\xampplite\htdocs\www\jobberbase\public\page_write.php on line 136

    Warning: Cannot modify header information – headers already sent by (output started at C:\xampplite\htdocs\www\jobberbase\public\page_write.php:113) in C:\xampplite\htdocs\www\jobberbase\public\_includes\function.redirect_to.php on line 30

    Can someone explain me where I have do define ‘apply_photo’ other than in the template file? your help is much appreciated.

  5. Thanks for the instructions. I successfully implemented it for 1.9.1. I only changed direction for (1) On /_includes/translations.ini, add under [apply]) to (1) On /_templates/default/_translations/translations.ini, add under [apply]).

  6. Hi
    How to upload more than 1 photo?

    Thanks

  7. It sends the email allright but it does not give the “Sucesfull sent” screen.
    Instead it gives following error:

    Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/offertdi/public_html/sezonac.com/_includes/class.phpmailer.php on line 1350

    Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/offertdi/public_html/sezonac.com/_includes/class.phpmailer.php on line 1354

    Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/offertdi/public_html/sezonac.com/_includes/class.phpmailer.php on line 1350

    Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/offertdi/public_html/sezonac.com/_includes/class.phpmailer.php on line 1354

    Warning: Cannot modify header information – headers already sent by (output started at /home/offertdi/public_html/sezonac.com/_includes/class.phpmailer.php:1350) in /home/offertdi/public_html/sezonac.com/_includes/function.redirect_to.php on line 59

    Maybe this has something to do with magic quotes settin?

Leave a Response