just tryin to suss file uploads...
got my image > database uploads working but for some reason i cant get image > folder working.
probubly going to be really silly mistake but, the followin script displays the unknown error.
Anyone know why?
Runnin latest version pf PHP & apache on windows xp pro π
never had a problem with uploads on a linux based box π
<?php
error_reporting(0);
// declare max dimensions:
$width = "150";
$height = "150";
// declare max file size in bytes
$size = "153600";
// declare upload directory - is this right? - first tested with the path to my apache htdocs folder but changed it to c:\php as i thouh spaces where messing it up.
$directory = "c:/PHP/";
if ($_REQUEST[submit]) {
// get image dimensions/file size
$image_details = getimagesize($_FILES[form_data][tmp_name]);
// check file is an image file
if($image_details == FALSE) {
echo "File is not an image!";
exit;
}
// check dimensions
if($image_details[0] > $width or $image_details[1] > $height) {
echo "Dimensions are too big!";
exit;
}
// check file size
if($_FILES[form_data][size] > $size) {
echo "File size is too big!";
exit;
}
// unsure about this bit too!
$upload_file = move_uploaded_file($_FILES[userfile][tmp_name], $directory . $_FILES[userfile][name]);
if($upload_file == FALSE) {
echo "Unknown error occured uploading file!";
exit;
} else {
echo "File uploaded OK";
}
} else {
?>
<form method="post" action="<?php echo $_SERVER[PHP_SELF]; ?>" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
File to upload/store in database:<br>
<input type="file" name="form_data" size="40">
<p><input type="submit" name="submit" value="submit">
</form>
<?php
}
?>
tried echoing $_FILES['userfile']['error'] but nothing appears π
Thanksπ