Jump to content

Recommended Posts

guys,

 

i need help, i have a form a application form wherein the applicant

has to attach his/her photo and resume

 

my problem is, the applcation can be submitted successfully

but the file could not be uploaded

 

need help on this please

below is the codes for my form

<form action="resume/addresume.php" method="post" enctype="multipart/form-data">
                      <tr>
                        <td align="right" valign="top" class="text6">Upload Photo : </td>
                        <td> </td>
                        <td><input type="file" name="photofile" /></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6">Upload Resume : </td>
                        <td> </td>
                        <td><input type="file" name="resume" /></td>
                      </tr>
                      <tr>
                        <td align="right" valign="top" class="text6"> </td>
                        <td> </td>
                        <td><input type="submit" name="Submit" value="Register"></td>
                      </tr>

 

and this is my code for my addresume.php

 

<?
session_start();

if (session_is_registered("username")){
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}

include '../db_connect.php';

$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$daybirth = $_POST['daybirth'];
$monthbirth = $_POST['monthbirth'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$state = $_POST['state'];
$specialization = implode("\n", $_POST['specialization']);
$level = $_POST['level'];
//$photofile = $_POST['photofile'];
//$resume = $_POST['resume'];
$learned = $_POST['learned'];
$dateregistered = date('d-m-Y');
// 0000-00-00
$datebirth = $yearbirth.'-'.$monthbirth.'-'.daybirth;

//email verification 1
if ($email1 == $email2){
	$email = $email1;
	$username = $email1;
	}else { 
		echo '<script language=javascript>alert("Email Address does not match!");top.location = "../resumemngr.php?id=1";</script>';
}
//email verification 2
$sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'");
  $username_check = mysql_num_rows($sql_username_check);
	if($username_check > 0){
		echo '<script language=javascript> alert("Email is already used!");top.location = "../resumemngr.php?id=1";</script>';
		unset($username);
		exit();
	} 	 
//password verification
if ($password1 == $password2){
	$password = ($password1);
	}else { 
		echo '<script language=javascript>alert("Password does not match!");top.location = "../resumemngr.php?id=1";</script>';
}

//set this to the directory where resume files will be uploaed
$uploaddir = '/c:/hosting/webhost4life/member/diorgrace/admean/pHotos';
$uploadfile = $uploaddir . basename($_FILES['resume']['username']);

if (move_uploaded_file($_FILES['resume']['username'], $uploadfile)) {
    echo "File is uploaded.";
} else {
    echo "File could not be uploaded";
}
//set this to the directory where photo files will be uploaded
$uploaddir = '/c:/hosting/webhost4life/member/diorgrace/admean/reSumes';
$uploadfile = $uploaddir . basename($_FILES['photofile']['username']);

if (move_uploaded_file($_FILES['photofile']['username'], $uploadfile)) {
    echo "File is uploaded.";
} else {
    echo "File could not be uploaded";
}

$email = stripslashes($email);
$username = stripslashes($username);
$password = stripslashes($password);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$datebirth = stripslashes($datebirth);
$gender = stripslashes($gender);
$country = stripslashes($country);
$state = stripslashes($state);
$specialization = stripslashes($specialization);
$level = stripslashes($level);
//$photofile = stripslashes($photofile);
//$resume = stripslashes($resume);
$learned = stripslashes($learned);
$dateregistered = stripslashes($dateregistered);

$db_password = md5($password);

$sql = mysql_query("INSERT INTO applicant (email, username, password, fname, lname, datebirth, gender, country, state, specialization, level, learned, dateregistered )
      VALUES('$email', '$username', '$db_password', '$fname', '$lname', '$datebirth', '$gender', '$country', '$state', '$specialization', '$level', '$learned', '$dateregistered')") or die (mysql_error());

     if(!$sql){
    echo '<script language=javascript> alert("Error adding applicant");top.location = "../resumemngr.php?id=1";</script>';
	exit();
     } else {
   $appid = mysql_insert_id();	   
   echo '<script language=javascript> alert("New Applicant has been added by!");top.location = "../resumemngr.php?id=1";</script>';
     }
?>

 

i dont know if my codes for the file upload is wrong or

my directory location.

hope you could help me with this.

 

thanks a lot!

Link to comment
https://forums.phpfreaks.com/topic/40022-solved-need-help-on-my-submit-form/
Share on other sites

this is the error message that i am getting now

 

Warning: move_uploaded_file(/c:/hosting/webhost4life/member/diorgrace/admean/pHotos/php2844.tmp):failed to open stream: Invalid argument in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 57

 

warning: move_uploaded_file():Unable to move 'C:\PHP\uploadtemp\php2844.tmp' to '/c:/hosting/webhost4life/member/diorgrace/admean/pHotos/php2844.tmp' in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 57

file could not be uploaded

 

Warning: move_uploaded_file(/c:/hosting/webhost4life/member/diorgrace/admean/reSumes/php2843.tmp):failed to open stream: Invalid argument in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 66

 

warning: move_uploaded_file():Unable to move 'C:\PHP\uploadtemp\php2843.tmp' to '/c:/hosting/webhost4life/member/diorgrace/admean/reSumes/php2843.tmp' in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 66

file could not be uploaded

 

 

this is my current code now in addresume.php

<?
session_start();

if (session_is_registered("username")){
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}

include '../db_connect.php';

$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$daybirth = $_POST['daybirth'];
$monthbirth = $_POST['monthbirth'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$state = $_POST['state'];
$specialization = implode("\n", $_POST['specialization']);
$level = $_POST['level'];
//$photofile = $_POST['photofile'];
//$resume = $_POST['resume'];
$learned = $_POST['learned'];
$dateregistered = date('d-m-Y');
// 0000-00-00
$datebirth = $yearbirth.'-'.$monthbirth.'-'.daybirth;

//email verification 1
if ($email1 == $email2){
	$email = $email1;
	$username = $email1;
	}else { 
		echo '<script language=javascript>alert("Email Address does not match!");top.location = "../resumemngr.php?id=1";</script>';
}
//email verification 2
$sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'");
  $username_check = mysql_num_rows($sql_username_check);
	if($username_check > 0){
		echo '<script language=javascript> alert("Email is already used!");top.location = "../resumemngr.php?id=1";</script>';
		unset($username);
		exit();
	} 	 
//password verification
if ($password1 == $password2){
	$password = ($password1);
	}else { 
		echo '<script language=javascript>alert("Password does not match!");top.location = "../resumemngr.php?id=1";</script>';
}

//set this to the directory where resume files will be uploaed
$uploaddir = '/c:/hosting/webhost4life/member/diorgrace/admean/pHotos/';
$uploadfile = $uploaddir . basename($_FILES['resume']['tmp_name']);

if (move_uploaded_file($_FILES['resume']['tmp_name'], $uploadfile)) {
    echo "File is uploaded.";
} else {
    echo "File could not be uploaded";
}
//set this to the directory where photo files will be uploaded
$uploaddir = '/c:/hosting/webhost4life/member/diorgrace/admean/reSumes/';
$uploadfile = $uploaddir . basename($_FILES['photofile']['tmp_name']);

if (move_uploaded_file($_FILES['photofile']['tmp_name'], $uploadfile)) {
    echo "File is uploaded.";
} else {
    echo "File could not be uploaded";
}

$email = stripslashes($email);
$username = stripslashes($username);
$password = stripslashes($password);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$datebirth = stripslashes($datebirth);
$gender = stripslashes($gender);
$country = stripslashes($country);
$state = stripslashes($state);
$specialization = stripslashes($specialization);
$level = stripslashes($level);
//$photofile = stripslashes($photofile);
//$resume = stripslashes($resume);
$learned = stripslashes($learned);
$dateregistered = stripslashes($dateregistered);

$db_password = md5($password);

$sql = mysql_query("INSERT INTO applicant (email, username, password, fname, lname, datebirth, gender, country, state, specialization, level, learned, dateregistered )
      VALUES('$email', '$username', '$db_password', '$fname', '$lname', '$datebirth', '$gender', '$country', '$state', '$specialization', '$level', '$learned', '$dateregistered')") or die (mysql_error());

     if(!$sql){
    echo '<script language=javascript> alert("Error adding applicant");top.location = "../resumemngr.php?id=1";</script>';
	exit();
     } else {
   $appid = mysql_insert_id();	   
   echo '<script language=javascript> alert("New Applicant has been added by!");top.location = "../resumemngr.php?id=1";</script>';
     }
?>

 

hope you could help me with this.

 

thanks!

hi,

 

i am still getting some errors in uploading files

 

Warning: move_uploaded_file(reSumes/resume.doc):failed to open stream: No such file or directory in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 57

 

warning: move_uploaded_file():Unable to move 'C:\PHP\uploadtemp\php28AA.tmp' to 'reSumes/resume.doc' in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 57

There was an error uploading the file, please try again!

 

Warning: move_uploaded_file(uploads/pic.jpg):failed to open stream: No such file or directory in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 68

 

warning: move_uploaded_file():Unable to move 'C:\PHP\uploadtemp\php28A9.tmp' to 'uploads/pic.jpg' in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 68

There was an error uploading the file, please try again!

 

 

what could be the problem here?

 

below is my codes for my addresume.php

<?
session_start();

if (session_is_registered("username")){
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}

include '../db_connect.php';

$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$daybirth = $_POST['daybirth'];
$monthbirth = $_POST['monthbirth'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$state = $_POST['state'];
$specialization = implode("\n", $_POST['specialization']);
$level = $_POST['level'];
//$photofile = $_POST['photofile'];
//$resume = $_POST['resume'];
$learned = $_POST['learned'];
$dateregistered = date('d-m-Y');
// 0000-00-00
$datebirth = $yearbirth.'-'.$monthbirth.'-'.daybirth;

//email verification 1
if ($email1 == $email2){
	$email = $email1;
	$username = $email1;
	}else { 
		echo '<script language=javascript>alert("Email Address does not match!");top.location = "../resumemngr.php?id=1";</script>';
}
//email verification 2
$sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'");
  $username_check = mysql_num_rows($sql_username_check);
	if($username_check > 0){
		echo '<script language=javascript> alert("Email is already used!");top.location = "../resumemngr.php?id=1";</script>';
		unset($username);
		exit();
	} 	 
//password verification
if ($password1 == $password2){
	$password = ($password1);
	}else { 
		echo '<script language=javascript>alert("Password does not match!");top.location = "../resumemngr.php?id=1";</script>';
}

//set this to the directory where resume files will be uploaed
$target_path = 'reSumes/';
$target_path = $target_path . basename($_FILES['resume']['name']);

if(move_uploaded_file($_FILES['resume']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['resume']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

//set this to the directory where photo files will be uploaded
$target_path = 'uploads/';
$target_path = $target_path . basename($_FILES['photofile']['name']);

if(move_uploaded_file($_FILES['photofile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['photofile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}



$email = stripslashes($email);
$username = stripslashes($username);
$password = stripslashes($password);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$datebirth = stripslashes($datebirth);
$gender = stripslashes($gender);
$country = stripslashes($country);
$state = stripslashes($state);
$specialization = stripslashes($specialization);
$level = stripslashes($level);
//$photofile = stripslashes($photofile);
//$resume = stripslashes($resume);
$learned = stripslashes($learned);
$dateregistered = stripslashes($dateregistered);

$db_password = md5($password);

$sql = mysql_query("INSERT INTO applicant (email, username, password, fname, lname, datebirth, gender, country, state, specialization, level, learned, dateregistered )
      VALUES('$email', '$username', '$db_password', '$fname', '$lname', '$datebirth', '$gender', '$country', '$state', '$specialization', '$level', '$learned', '$dateregistered')") or die (mysql_error());

     if(!$sql){
    echo '<script language=javascript> alert("Error adding applicant");top.location = "../resumemngr.php?id=1";</script>';
	exit();
     } else {
   $appid = mysql_insert_id();	   
   echo '<script language=javascript> alert("New Applicant has been added by!");top.location = "../resumemngr.php?id=1";</script>';
     }
?>

 

 

hope you could help me with this.

 

thanks!

 

hi,

 

i did that, this is now the error message that i am getting

 

Warning: move_uploaded_file(reSumes/resume.doc):failed to open stream: Permission denied in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 57

 

warning: move_uploaded_file():Unable to move 'C:\PHP\uploadtemp\php28AA.tmp' to 'reSumes/resume.doc' in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 57

There was an error uploading the file, please try again!

 

Warning: move_uploaded_file(uploads/pic.jpg):failed to open stream: Permission denied in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 68

 

warning: move_uploaded_file():Unable to move 'C:\PHP\uploadtemp\php28A9.tmp' to 'uploads/pic.jpg' in c:\hosting\webhost4life\member\diorgrace\admean\resume\addresume.php on line 68

There was an error uploading the file, please try again!

 

 

is this a permission problem in the folder or in the addresume.php page?

i checked the chmod of my upload folder and it was set to 666 already

 

what could be the problem here.

below is my current codes for addresume.php

 

<?
session_start();

if (session_is_registered("username")){
}else{
echo "<font face=\"Arial\">You are not authorized to access this page ... Please <a href='../index.php'>Login</a></font>";
}

include '../db_connect.php';

$email1 = $_POST['email1'];
$email2 = $_POST['email2'];
$password1 = $_POST['password1'];
$password2 = $_POST['password2'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$daybirth = $_POST['daybirth'];
$monthbirth = $_POST['monthbirth'];
$gender = $_POST['gender'];
$country = $_POST['country'];
$state = $_POST['state'];
$specialization = implode("\n", $_POST['specialization']);
$level = $_POST['level'];
//$photofile = $_POST['photofile'];
//$resume = $_POST['resume'];
$learned = $_POST['learned'];
$dateregistered = date('d-m-Y');
// 0000-00-00
$datebirth = $yearbirth.'-'.$monthbirth.'-'.$daybirth;

//email verification 1
if ($email1 == $email2){
	$email = $email1;
	$username = $email1;
	}else { 
		echo '<script language=javascript>alert("Email Address does not match!");top.location = "../resumemngr.php?id=1";</script>';
}
//email verification 2
$sql_username_check = mysql_query("SELECT username FROM applicant WHERE email='$email'");
  $username_check = mysql_num_rows($sql_username_check);
	if($username_check > 0){
		echo '<script language=javascript> alert("Email is already used!");top.location = "../resumemngr.php?id=1";</script>';
		unset($username);
		exit();
	} 	 
//password verification
if ($password1 == $password2){
	$password = ($password1);
	}else { 
		echo '<script language=javascript>alert("Password does not match!");top.location = "../resumemngr.php?id=1";</script>';
}

//set this to the directory where resume files will be uploaed
$target_path = 'uploads/';
$target_path = $target_path . basename($_FILES['resume']['name']);

if(move_uploaded_file($_FILES['resume']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['resume']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

//set this to the directory where photo files will be uploaded
$target_path = 'uploads/';
$target_path = $target_path . basename($_FILES['photofile']['name']);

if(move_uploaded_file($_FILES['photofile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['photofile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}



$email = stripslashes($email);
$username = stripslashes($username);
$password = stripslashes($password);
$fname = stripslashes($fname);
$lname = stripslashes($lname);
$datebirth = stripslashes($datebirth);
$gender = stripslashes($gender);
$country = stripslashes($country);
$state = stripslashes($state);
$specialization = stripslashes($specialization);
$level = stripslashes($level);
//$photofile = stripslashes($photofile);
//$resume = stripslashes($resume);
$learned = stripslashes($learned);
$dateregistered = stripslashes($dateregistered);

$db_password = md5($password);

$sql = mysql_query("INSERT INTO applicant (email, username, password, fname, lname, datebirth, gender, country, state, specialization, level, learned, dateregistered )
      VALUES('$email', '$username', '$db_password', '$fname', '$lname', '$datebirth', '$gender', '$country', '$state', '$specialization', '$level', '$learned', '$dateregistered')") or die (mysql_error());

     if(!$sql){
    echo '<script language=javascript> alert("Error adding applicant");top.location = "../resumemngr.php?id=1";</script>';
	exit();
     } else {
   $appid = mysql_insert_id();	   
   echo '<script language=javascript> alert("New Applicant has been added by!");top.location = "../resumemngr.php?id=1";</script>';
     }
?>

 

need help please!

 

thanks!

make sure the webserver has permission to write to it

No, you didn't. Permissions of any files php will be moving files to (your upload directory and your reSume directory) should be 777, not 666. Do that and try it again.

 

You marked this as solved. Did you figure it out or are you still getting that error message.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.