FORUMS: list search recent posts

PHP picture submission

COW Forums : Web Design

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Robbo Ando
PHP picture submission
on Apr 22, 2009 at 11:15:57 pm

Hi,
I'm very new to PHP - unbelievably new.
I'm using dreamweaver and a customizable website script for a picture submission form, and also an information submission form.

http://www.thatsfishing.com.au/ this is the website being worked on

this is the code for the form on a page which is not reachable yet (

<form ><form form1"action="Scripts/upload.php" method="post" enctype="multipart/form-data">
<p>
<label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br />
<button>Upload File</button>
<p>
</form>


//<form ><form form1"action="Scripts/upload.php" method="post" enctype="multipart/form-data">
//<p>
//<label for="file">Select a file:</label> <input type="file" name="userfile" id="file"> <br />
//<button>Upload File</button>
//<p>
//</form>


and my PHP document code:


//<?php
// Configuration - Your Options
$allowed_filetypes = array('.jpg','.gif','.bmp','.png'); // These will be the types of file that will pass the validation.
$max_filesize = 524288; // Maximum filesize in BYTES (currently 0.5MB).
$upload_path = 'upload/'; // The place the files will be uploaded to (currently a 'files' directory).

$filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
$ext = substr($filename, strpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.

// Check if the filetype is allowed, if not DIE and inform the user.
if(!in_array($ext,$allowed_filetypes))
die('The file you attempted to upload is not allowed. We allow JPG, GIF, BMP and PNG pictures');

// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
die('The file you attempted to upload is too large. The maximum file size allowed is 500kbs');

// Check if we can upload to the specified path, if not DIE and inform the user.
if(!is_writable($upload_path))
die('You cannot upload to the specified directory, please CHMOD it to 777.');

// Upload the file to your specified path.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
echo 'Your file upload was successful, view the file <a href="' . $upload_path . $filename . '" title="Your File">here</a>'; // It worked.
else
echo 'There was an error during the file upload. Please try again.'; // It failed :(.

?>

(the opening php tag < ? php is disappearing here)

with information included in the code ->
what do I have wrong? i have it all linked up properley in dreamweaver (the form to the PHP coding) so why wont the picture submit


Return to posts index

Robbo Ando
Re: PHP picture submission
on Apr 27, 2009 at 12:04:00 am

Still having trouble - >

using a different code but I keep getting Access Denied when I upload so I can't even test the form

<?php

/*Subject and email variables */

$emailSubject = 'Thats Fishing Contact Form';
$webMaster = 'fish@thatsfishing.com.au';

/*Gathering data variables*/

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$commentField = $_POST['comment'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Comment: $comment <br>
EOD;

$headers = "From: $emailrn";
$headers .= "Content-type: text/htmlrn";
$success = mail($webMaster, $emailSubject, $body, $headers);

/*Results as HTML*/
$theResults = <<<EOD
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>
<body>
Good
</body>
</html>
EOD;
echo "$theResults";

?>


Return to posts index

Fernando Mol
Re: PHP picture submission
on Apr 28, 2009 at 9:44:20 pm

Are you getting access denied from inside dreamweaver (FTP problem) or when you actually try to test the page in your server?

Can you write the exact error message?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]