Hi, I am just starting with PHP and I am trying to run an upload script that takes an img file and stores it on my host ftp.
I have tried many many scripts from different places on the web and have yet to find one that works for me.
This is the script I am currently trying:
<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="imagefile">
<input type="submit" name="Submit" value="Submit">
<?
if(isset( $Submit ))
{
//If the Submitbutton was pressed do:
if ($FILES['imagefile']['type'] == "image/gif"){
copy ($FILES['imagefile']['tmp_name'], "files/".$FILES['imagefile']['name'])
or die ("Could not copy");
echo "";
echo "Name: ".$FILES['imagefile']['name']."";
echo "Size: ".$FILES['imagefile']['size']."";
echo "Type: ".$FILES['imagefile']['type']."";
echo "Copy Done....";
}
else {
echo "";
echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")";
}
}
?> </form>
When I click Submit, nothing happens, it just refreshes the form.
Note: I want to be able to upload to the /images/upload/ directory.
I would really appreciate help on this as I am completely lost.
- Code examples would be very helpful as well.
Thanks
Andrew