trouble with upload

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sublevel4
Forum Commoner
Posts: 33
Joined: Wed May 29, 2002 2:14 pm
Contact:

trouble with upload

Post 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
User avatar
Zoram
Forum Contributor
Posts: 166
Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:

Post 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
Post Reply