PHP Form

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

I'm trying to upload a file via a form in PHP, along with other data. For some reason it won't upload the file. Can you see anything wrong here?

<?php
include(\"header.php\");
// Receiving variables
@
$pfw_ip= $_SERVER['REMOTE_ADDR'];
@
$first_name = addslashes($_GET['first_name']);
@
$address = addslashes($_GET['address']);
@
$city = addslashes($_GET['city']);
@
$state = addslashes($_GET['state']);
@
$phone = addslashes($_GET['phone']);
@
$email = addslashes($_GET['email']);
@
$apply = addslashes($_GET['apply']);
@
$resume_Name = $_FILES['resume']['name'];
@
$resume_Size = $_FILES['resume']['size'];
@
$resume_Temp = $_FILES['resume']['tmp_name'];
@
$resume_Mime_Type = $_FILES['resume']['type'];

function RecursiveMkdir(
$path)
{
   if (!file_exists(
$path))
   {
      RecursiveMkdir(dirname(
$path));
      mkdir(
$path, 0777);
    }
  }


// Validation



$uploadFile = \"resume/\".$resume_Name ;
if (!is_dir(dirname(
$uploadFile)))
  {
    @RecursiveMkdir(dirname(
$uploadFile));
  }
else
  {
  @chmod(dirname(
$uploadFile), 0777);
  }
@move_uploaded_file(
$resume_Temp , $uploadFile);
chmod(
$uploadFile, 0644);
$resume_URL = \"http://pbing.com/farmers/resume/\".$resume_Name ;

//Sending Email to form owner
$pfw_header = \"From: $email\n\"
  . \"Reply-To:
$email\n\";
$pfw_subject = \"This is a test\";
$pfw_email_to = \"[email protected]\";
$pfw_message = \"Visitor's IP: $pfw_ip\n\"
. \"first_name:
$first_name\n\"
. \"address:
$address\n\"
. \"city:
$city\n\"
. \"state:
$state\n\"
. \"phone:
$phone\n\"
. \"email:
$email\n\"
. \"apply:
$apply\n\"
. \"resume:
$resume_URL\n\";
@mail(
$pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo(\"<p align='center'><font face='Arial' size='3' color='#FF0000'>Thanks</font></p>\");
include(\"footer.php\");
?>

The error I get is Warning: chmod(): Operation not permitted in /home/pbing/public_html/farmers/apply2.php on line 50. I get the email with all the data but in the email it only shows "resume: http://pbing.com/farmers/resume/" when it should be like "...resume/file.ext"

Renegade's picture

He has: 3,022 posts

Joined: Oct 2002

If it's giving a chmod() error, it means that you're not allowed to use the chmod() function - some hosts don't allow it Plain

Busy's picture

He has: 6,151 posts

Joined: May 2001

Also make sure the folder (resume) has been chmod'd so is writable

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

The folder was chmod 777, so I think my host doesn't allow it. Is there a way to attach the file without that chmod() thing? This is my first attempt at something like this so I need a little help Smiling Thanks!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.