Page 1 of 1

trouble with upload

Posted: Tue Oct 22, 2002 1:01 pm
by sublevel4
i have an upload html file like this

Code: Select all

<form action="upload.php" method="post" ENCTYPE="multipart/form-data"> 
   <input type="file" size=40 name="file"><br> 
   <input type="hidden" name="MAX_FILE_SIZE" value="100000"> 
   <input type="submit" value="upload"> 
   </form>
and a php file like:

Code: Select all

<?php
        if ($file == "none") { 
            print "You must specify a file to upload"; 
        } 
        else { 
        copy($file, "/images/$file_name"); 
        unlink($file); 
        } 
    
?>
It is not working.
I wanted to know what i have gotten wrong or it it is something else besides the code.
Thanks for any help

Posted: Tue Oct 22, 2002 1:12 pm
by Zoram
try:

Code: Select all

<?php
if (isset($_FILESї'file'])) {
   move_uploaded_file ($_FILESї'file']ї'tmp_name'], "images");
   print ("File Uploaded.");
} else {
   print ("You must specify a file to upload"
}
?>
I'm not sure if it's totally right...

You might also put :

Code: Select all

<?php
if (is_writable ("images")) { print ("File Writable"); } else { print("File NOT writable"); }
?>
To check to make sure that you can write to the file