Jump to content

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

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.