Jump to content

Trouble using upload script


thedualmind

Recommended Posts

I went through a couple of tutorials before bothering anyone, however I still cannot seem to get past an error from the upload_file_with_validation function. I am new to PHP and I am very eager to learn, however I keep running into walls. I used the Writing A file Upload Class tutorial by BinaryStar which helped me to understand the scripting process much better. My goal right now is just to learn how to get a script to work and there is obviously something I am missing here. I would definitely appreciate anyones help. Here is the script I used. The error message will be posted below it:

 

<?php

function upload_file_with_validation() {

    //SECTION #1

    $temp_file_name = trim($this->temp_file_name);

    $file_name = trim(strtolower($this->file_name));

    $upload_dir = $this->get_upload_directory();

    $upload_log_dir = $this->get_upload_log_directory();

    $file_size = $this->get_file_size();

    $ip = trim($_SERVER['REMOTE_ADDR']);

    $cpu = gethostbyaddr($ip);

    $m = date("m");

    $d = date("d");

    $y = date("Y");

    $date = date("m/d/Y");

    $time = date("h:i:s A");

    $existing_file = $this->existing_file();    //<-Add On

    $valid_user = $this->validate_user();        //<-Add On

    $valid_size = $this->validate_size();        //<-Add On

    $valid_ext = $this->validate_extension();    //<-Add On

 

    //SECTION #2

    if (($upload_dir == "ERROR") OR ($upload_log_dir == "ERROR")) {

        return false;

    }

    elseif ((((!$valid_user) OR (!$valid_size) OR (!$valid_ext) OR ($existing_file)))) {

        return false;

    } else {

        if (is_uploaded_file($temp_file_name)) {

            if (move_uploaded_file($temp_file_name,$upload_dir . $file_name)) {

                $log = $upload_log_dir.$y."_".$m."_".$d.".txt";

                $fp = fopen($log,"a+");

                fwrite($fp,"

$ip-$cpu | $file_name | $file_size | $date | $time");

                fclose($fp);

                return true;

            } else {

                return false;

            }

        } else {

            return false;

        }

    }

}

?>

 

Error Message Appears to be a directory upload problem:

 

Parse error: parse error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/content/t/h/e/thedualmind/html/policy.php on line 16

 

Link to comment
Share on other sites

I think we're getting somewhere .  I deleted a file named policy.php in the main html directory. Now when I try to submit the upload on the webpage I get a page now found message which sounds like now we just need to get the right policy.php in the right php folder. 

Link to comment
Share on other sites

I think we're getting somewhere .  I deleted a file named policy.php in the main html directory. Now when I try to submit the upload on the webpage I get a page now found message which sounds like now we just need to get the right policy.php in the right php folder. 

 

you really need to find the policy.php thats the only way to sort the prob

 

and one thing for sure you have that file or else you wont have that error message

Link to comment
Share on other sites

I have the file posted under the following path: /php_uploads/gdforms.php/policy.php.

However it seems to only recognize the file being present when it is in the main directory, which is the html directory. You think that my directory setup is not good or maybe my form code is the problem. I can post that if you think that could be an issue.

Link to comment
Share on other sites

I got the form to go to the policy.php page after being submitted. However, the files did not seem to get uploaded. On my php script for the parts:

 

$upload_dir = $this->get_upload_directory();

    $upload_log_dir = $this->get_upload_log_directory();

 

Do I need to type in my own directory here. If not, is there anywhere in particular that I need to place my actual directory path in the script

Link to comment
Share on other sites

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.