q. Script to allow users to upload photos

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am trying to create a php script to allows users to upload photos:

The first file looks like this:



<title>Upload Photo</title>



<BODY LINK="#0000ff" VLINK="#800080" BACKGROUND="./wall.jpg">


<Font Size =4/><B/>Upload Photo For Teacher Card: <br><br><br></Font Size

<form action="UploadPhoto2.php" enctype="multipart/form-data" method="POST">

<input type="hidden" name="MAX_FILE_SIZE" value="51200">

File to Upload: <input type="file" name="fileupload"><br><br>

<input type="submit" value="Upload!">




It calls the second file that looks like this:



<title>Listing 9.14 A file upload script</title>



<h1>File had been uploaded successfully</h1>



</FONT><P><P ALIGN="LEFT"></FONT>&nbsp;&nbsp;&nbsp;&nbsp;<A
HREF="http://www.teachercards.org "><FONT SIZE=3>Return Home</FONT></A></P>


$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_array['tmp_name']."<br>\n";

            print "name: ".$file_array['name']."<br>\n";

            print "type: ".$file_array['type']."<br>\n";

            print "size: ".$file_array['size']."<br>\n";

            if (is_uploaded_file($file_array['tmp_name'])) {

"$file_dir/$file_array[name]") or die ("Couldn't copy");

                        print "file was moved!<br><br>";





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.



Re: q. Script to allow users to upload photos

look at the gallery script on sourceforge
(http://sourceforge.net/projects/sphp ) for some ideas and hints ...
it's a bit more developed, but it still sticks to basics (no db)

Site Timeline