upload file doesn't work
Posted: Tue Jul 07, 2009 10:59 pm
I am new to using PHP, been learning it for the past two months. I am not sure why this isn't working. Can anyone help? I'd really appreciate it.
Thanks
Code: Select all
<?php
if (array_key_exists('upload', $_POST)) {
// define constant for upload folder
define('UPLOAD_DIR', '/public_html/pages/rapid_quote/uploads');
// replace any spaces in original filename with underscores
// at the same time, assign to a simpler variable
$file = str_replace(' ', '_', $_FILES['uploadedfile']['name']);
// move the file to the upload folder and rename it using date stamp
ini_set('date.timezone', 'America/Los_Angeles');
$now = date('Y-m-d-His');
$success = move_uploaded_file($_FILES['uploadedfile']['tmp_name'],
UPLOAD_DIR.$now.$file);
"Stored in: " . "upload/" . $_FILES["file"]["name"];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
</p>
<form action="" method="post" enctype="multipart/form-data" name="uploadModel" id="uploadModel">
<p>
<label for="image">Upload model:</label>
<input type="file" name="uploadedfile" id="uploadedfile" />
</p>
<p>
<input name="send" id="send" type="submit" value="Send message" />
</p>
</form>
</body>
</html>