something like Goto?
Posted: Tue Apr 22, 2008 1:50 pm
Code: Select all
<?php
if (!isset($_POST['upload']))
exit();
if ($_FILES['pix']['tmp_name'] == "none") {
echo "<p style = 'font-weight: bold;'>File didn't successfully upload. Check he file size. File must be less than 500K.</p>";
exit();
}
if (!preg_match("/image/", $_FILES['pix']['type'])) {
echo "<p style = 'font-weight: bold';>The file has to be an image.";
exit();
}
$destination = 'C:\data' . "\\" . $_FILES['pix']['name'];
$temp_file = $_FILES['pix']['tmp_name'];
move_uploaded_file($temp_file, $destination);
echo "<p style = 'font-weight: bold';>The file has been successfully uploaded: {$_FILES['pix']['name']} - {$_FILES['pix']['size']}</p>";
?>
<html>
<head>
<title>form_with_upload</title>
</head>
<body>
<ol>
<li>Enter the file name</li>
<li>Click Upload Picture</li>
</ol>
<div style = 'text-align: center'><hr />
<form enctype = "multipart/form-data" action = "<?php $_SERVER['PHP_SELF']; ?>" method = "post">
<P><input type = "hidden" name = "MAX_FILE_SIZE" value = "500000" />
<input type = "file" name = "pix" size = "60" /></p>
<input type = "hidden" name = "submitted" value = "1" />
<input type = "submit" name = "upload" value = "Upload Picture">
</form>
</div>
</body>
</html>