Jump to content

Upload Script - now notifies me of upload details, but doesnt upload!


skot

Recommended Posts

Hi All & Good Morning..

 

I've got further than previously when I asked for help on this a couple of weeks back, but now I have one part of my script working, another now doesn't..

 

The page is here: www.centurysoftware.co.uk/upload.html

 

Basically the first page is a simple form where the user selects which file they want to upload to the server. The form posts to cs_uploadnotify.php, which should (but doesn't) confirm whether or not the upload was successful, then ask the user to fill out another form with their details so we know where the upload has come from.

 

The form then posts to cs_sendnotify.php which emails the details to me. Previously I had trouble getting these details to post across, but the upload worked, now it's the other way around! I've been trying different things and have hit a stump.. I cant see why its not working and could use a little help please.

 

If it is of more use to you i can upload all relevant files for you to have a look at - let me know. Thanks for your time.

 

 

Relevant code for first page:

       <form action="cs_uploadnotify.php" method="post" enctype="multipart/form-data" name="uploader" id="uploader" >
         <center>
           <label>           </label>
           <p><span class="style8"><span class="style12">Step 1: Browse to your file below...</span><br />
           <br />
           </span>
             <input name="myfile" type="file" class="style9" size="70" />
             <br />
             <input name="msg" type="hidden" id="msg" value="<?php echo $msg ?>" />
             <input name="error" type="hidden" id="error" value="<?php echo $error ?>" />
             <br />
         <img src="http://centurysoftware.co.uk/img/dot_line.gif" /></p>
           <p>
             <input name="submit" type="submit" class="connectbutton" id="submit" value="      Step 2: Upload File      " />
              <BR>
             <label>
       </form>

 

Code for cs_uploadnotify:

<?php
/*************************************************
* Max's File Uploader
*
* Version: 1.0
* Date: 2007-11-26
*
****************************************************/
class maxUpload{
    var $uploadLocation;
    
    /**
     * Constructor to initialize class varaibles
     * The uploadLocation will be set to the actual 
     * working directory
     *
     * @return maxUpload
     */
    function maxUpload(){
        $this->uploadLocation = getcwd().DIRECTORY_SEPARATOR;
    }

    /**
     * This function sets the directory where to upload the file
     * In case of Windows server use the form: c:\\temp\\
     * In case of Unix server use the form: /tmp/
     *
     * @param String Directory where to store the files
     */
    function setUploadLocation($dir){
        $this->uploadLocation = $dir;
    }
    
    function showUploadForm($msg='',$error=''){
?>

            <?php
    }

    function uploadFile(){
        if (!isset($_POST['submit'])){
            $this->showUploadForm();
		} else {
            $msg = '';
            $error = '';
            
            //Check destination directory
            if (!file_exists($this->uploadLocation)){
                $error = " The target directory doesn't exist! Please notify [email protected]";
            } else if (!is_writeable($this->uploadLocation)) {
                $error = " The target directory is not writeable! Please notify [email protected]";
            } else {
                $target_path = $this->uploadLocation . basename( $_FILES['myfile']['name']);

                if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
                    $msg = basename( $_FILES['myfile']['name']).
                    " was uploaded successfully!";
                } else {
                    $error = " <B>The upload process failed! Please try again.</B>";
                }
            }

            $this->showUploadForm($msg,$error);
        }

    }
}	
?>

 

Code for cs_sendnotify.php:

<?php

@extract($_POST);

$name = stripslashes($name);

$company = stripslashes($company);

$email = stripslashes($email);

$tel = stripslashes($tel);

$ufile = stripslashes($ufile);

$ip = stripslashes($ip);

$info = stripslashes($info);



mail('[email protected]','Data Upload From Website',"Hi\n\nSomeone has uploaded a file through the website.. Details as follows:\n\n\nName: $name \nCompany: $company \nTheir Email: $email \nTheir Phone No: $tel \n\nUploaded File: $ufile \n\nTheir IP address (logged for security purposes): $ip \n\nAdditional Info:\n$msg \n\n\nYou may download this file directly by copying the following link into your web brower..\n\nhttp://bridgey.net/century/$ufile","From: CenturySoftware.co.uk <[email protected]>") or die("Error");



// msg when sent....

echo "<BR><BR><BR><center><font face=Verdana,Tahoma,Arial,sans-serif size=3><B>We have been notified of your upload and will get back to you shortly if required.</b></font></center>";


?>

 

Resulting Email Output (all correct, although file is not on server):

 

Hi

 

Someone has uploaded a file through the website.. Details as follows:

 

 

Name: dfasdffsdf

Company: sdfsdf

Their Email: sdfsdfsdfds

Their Phone No: fdsfsdf

 

Uploaded File: AHS printer.docx

 

Their IP address (logged for security purposes): *purposely removed*

 

Additional Info:

 

 

 

You may download this file directly by copying the following link into your web brower..

 

http://bridgey.net/century/AHS printer.docx

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.