Jump to content

Uploading using PHP then redircetion doesn't work, help!


andy5898

Recommended Posts

Hi,

 

I am uploading to my website using the following script

 

<?php

// Check for a valid password to prevent unauthorised uploads

// Change 'password' to the name of the password field on your form (if there is one)

$pass = '';

if (isset($_POST['password'])) $pass = $_POST['password'];

 

// Change 'yourchoice' to the password you will use

// If you don't want to use a password, just specify ''

if ($pass != '') {

    die ('Password not recognised');

}

 

// Specify the types of file you want to allow, separated by commas

$allowedTypes = array('.jpg','.gif','.bmp','.png','.001','.xls','.doc');

// Specify the maximum file size you will accept

$maxsize = 10000000;

// Specify the folder that will receive the uploaded files, with trailing backslash

$destination = 'myfiles/';

// Replace 'formfile' with the name of the file browser field on your form

$upfile = $_FILES['formfile'];

 

if ($upfile['name']<>'') {

    if (is_uploaded_file($upfile['tmp_name'])) {

        $filetype = strstr (basename($upfile['name']),'.');

        $filetype = strtolower ($filetype);

        if (!in_array($filetype,$allowedTypes)) {

            die ("Invalid file format: ".$filetype." ".$upfile['type']);

        }

        $filesize = $upfile['size'];

        if ($filesize > $maxsize) {

            die ("File size exceeds maximum allowed");

        }

    } else {

        die ("This is not an uploaded file");

    }

} else {

    die ("Please specify a file name");

}

$filename = basename($upfile['name']);

$copyto = $destination.$filename;

move_uploaded_file($upfile['tmp_name'],$copyto)

header('Location: http://www.cbmaccounts.co.uk/successful.html/');

exit;

 

?>

 

 

It all works fine I can upload etc, but when it has uploaded successfully it won't take me to the page I want it too. Can anyone tell me what Im doing wrong and how I fix it?

 

Cheers

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.