View Full Version : Upload Word Docs
latemodern
05-09-2007, 04:44 PM
Hi,
I am trying to create a system that allows visitors to log in and upload their cv/resume in word format so that they can view it online and email it to potential employers. Is there an open source system available to achieve this?
Thanks
Chris
_Aerospace_Eng_
05-10-2007, 04:58 AM
This is what I use. Probably could be improved on.
<?php
session_start();
if(isset($_POST['submit']) && $_POST['submit'] == 'Upload Resume')
{
// Define the upload location
$target_path = "resumes/";
$self = $_SERVER['PHP_SELF'];
// Create the file name with path
$file_name = $_FILES['resume']['name'];
$file_ext = strtolower(substr($file_name,strrpos($file_name,".")));
$target_path = $target_path . basename($_SESSION['username']).'.doc';
// Try to move the file from the temporay directory to the defined.
if($file_ext != '.doc')
{
$error_msg = "The only allowed file type for resumes is a word document (.doc)";
$_SESSION['error'] = $error_msg;
header("Location: $self?error=1");
exit();
}
if(!move_uploaded_file($_FILES['resume']['tmp_name'], $target_path))
{
$error_msg = "There was an error uploading your resume, please try again!";
$_SESSION['error'] = $error_msg;
header("Location: $self?error=1");
exit();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" method="post">
<div>
<?php
if(isset($_GET['error'])) echo '<p>'.$_SESSION['error'].'</p>';
?>
<label for="resume">Upload Resume: <input type="file" name="resume" id="resume" /></label>
</div>
<input type="submit" name="submit" value="Upload Resume" />
</form>
</body>
</html>
latemodern
05-14-2007, 04:29 PM
Thanks for your help.
I was also looking for a way of viewing the doc online whilst retaining formatting etc.
Any ideas?
Thanks
rafiki
05-14-2007, 04:35 PM
does file_get_contents work?
rafiki
05-14-2007, 04:40 PM
oh and i think its printf or sprintf to keep it formatted how it was called!
aedrin
05-14-2007, 04:42 PM
It's a Word document. get_file_contents() on a Word document would show you random characters.
There might be a plugin out there you can find, Google Documents is able to do it but they probably made their own conversion.
Otherwise you're out of luck. It's not an easy task to do without any additional plugins.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.