Forum Moderators: coopster
<form action="test.php" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<input type="submit" name="Submit" value="Submit">
</form>
is this right? If so, can someone post the php code needed to make this work, or know where i can download one as i am nowhere even good at PHP... if it matters, I am using dreamweaver MX 2004
Thanks
<?php
if (is_uploaded_file($_FILES['file]['tmp_name'])
{
$destination_dir = 'some/dir/'
if (move_uploaded_file($_FILES['file']['tmp_name'], $destination_dir.basename($_FILES['file']['name'])))
{
echo 'successfully uploaded!';
} else {
echo 'file was not uploaded';
}
}
?>
This is very simple, so there's no validation in there. If the public has access to this form, then conceivably anything could be uploaded. You can read more about uploading files at:
[php.net...]
i keep getting this error:
Parse error: parse error, unexpected T_STRING, expecting ']' in /home/kydesi73/public_html/upload.php on line 2
here is what i have tried to change the upload dir to
$destination_dir = 'public_html/'
$destination_dir = '/public_html/'
$destination_dir = 'public_html'
$destination_dir = '/'
should the php file have a CHMOD of 777 (all access) or something?
maybe its not meant for me to be able to upload anything ... i changed the CHMOD to 777 on the php file and made the changes to line 2, not its giving an error for line 3.
anything else you can think of? Thanks for all the help so far tho!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Upload Reports</title>
</head>
<body>
<form action="upload.php" method="post" enctype="multipart/form-data" name="form1">
<input type="file" name="file">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
here is the current PHP code that will go along with this form, unchanged as i have it now:
<?php
{
(is_uploaded_file($_FILES['file']['tmp_name'])
$destination_dir = '/';
if (move_uploaded_file($_FILES['file']['tmp_name'], $destination_dir.basename($_FILES['file']['name'])))
{
echo 'successfully uploaded!';
} else {
echo 'file was not uploaded';
}
}
?>