I am trying to create a php script to allows users to upload photos:
The first file looks like this:
<html>
<head>
<title>Upload Photo</title>
</head>
<body>
<BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="./wall.jpg">
<br>
<Font Size =4/><B/>Upload Photo For Teacher Card: <br><br><br></Font Size
=4>
<form action="UploadP hoto2.php" enctype="multip art/form-data" method="POST">
<input type="hidden" name="MAX_FILE_ SIZE" value="51200">
File to Upload: <input type="file" name="fileuploa d"><br><br>
<input type="submit" value="Upload!" >
</form>
</body>
</html>
It calls the second file that looks like this:
<html>
<head>
<title>Listin g 9.14 A file upload script</title>
</head>
<body>
<h1>File had been uploaded successfully</h1>
<br>
<br>
</FONT><P><P ALIGN="LEFT"></FONT> &nbs p; < A
HREF="http://www.teachercard s.org"><FONT SIZE=3>Return Home</FONT></A></P>
<?php
$file_dir = "/uploads"; set up this directory wanting photos would be
uploaded here and it is not working.
foreach($_FILES as $file_name => $file_array) {
print "path: ".$file_arr ay['tmp_name']."<br>\n";
print "name: ".$file_arr ay['name']."<br>\n";
print "type: ".$file_arr ay['type']."<br>\n";
print "size: ".$file_arr ay['size']."<br>\n";
if (is_uploaded_fi le($file_array['tmp_name'])) {
move_uploaded_f ile($file_array['tmp_name'],
"$file_dir/$file_array[name]") or die ("Couldn't copy");
print "file was moved!<br><br>" ;
}
}
?>
</html>
I am pretty sure the problem is in the second file and the code just needs
to be made more specific to my web site. But not sure how to do it and
would appreciate some help.
TIA
David
The first file looks like this:
<html>
<head>
<title>Upload Photo</title>
</head>
<body>
<BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="./wall.jpg">
<br>
<Font Size =4/><B/>Upload Photo For Teacher Card: <br><br><br></Font Size
=4>
<form action="UploadP hoto2.php" enctype="multip art/form-data" method="POST">
<input type="hidden" name="MAX_FILE_ SIZE" value="51200">
File to Upload: <input type="file" name="fileuploa d"><br><br>
<input type="submit" value="Upload!" >
</form>
</body>
</html>
It calls the second file that looks like this:
<html>
<head>
<title>Listin g 9.14 A file upload script</title>
</head>
<body>
<h1>File had been uploaded successfully</h1>
<br>
<br>
</FONT><P><P ALIGN="LEFT"></FONT> &nbs p; < A
HREF="http://www.teachercard s.org"><FONT SIZE=3>Return Home</FONT></A></P>
<?php
$file_dir = "/uploads"; set up this directory wanting photos would be
uploaded here and it is not working.
foreach($_FILES as $file_name => $file_array) {
print "path: ".$file_arr ay['tmp_name']."<br>\n";
print "name: ".$file_arr ay['name']."<br>\n";
print "type: ".$file_arr ay['type']."<br>\n";
print "size: ".$file_arr ay['size']."<br>\n";
if (is_uploaded_fi le($file_array['tmp_name'])) {
move_uploaded_f ile($file_array['tmp_name'],
"$file_dir/$file_array[name]") or die ("Couldn't copy");
print "file was moved!<br><br>" ;
}
}
?>
</html>
I am pretty sure the problem is in the second file and the code just needs
to be made more specific to my web site. But not sure how to do it and
would appreciate some help.
TIA
David
Comment