q. Script to allow users to upload photos

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Willoughby Bridge

    q. Script to allow users to upload photos

    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>&nbsp;&nbs p;&nbsp;&nbsp;< 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


  • cyberhorse

    #2
    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)

    Comment

    Working...