[Solved] Script fails to interact with an upload form
Posted: Wed Aug 05, 2009 7:49 pm
Hello, I am really new to PHP and still learning off tutorials.
I copied a source code from a tutorial and fixed it to work without errors, but now it just doesn't do what its supposed to.
It is a completely basic upload form, you can see my failing result [with all the debug messages] here: http://frozenarmageddon.orgfree.com/upl ... loads2.php
I replaced a lot of stuff that didn't work for some reason with much simpler stuff that worked, But because it is 3:30 AM here I accidentally deleted my copy of the tutorial's source, so I can't show you what it was before I changed it.
Source [Sorry it seems like it won't let me upload it.]:
and it results in [Uploaded file called 124723746384.jpg]:
Ofcourse it didn't upload anything, and I checked the variable passing, its OK. so the problem must be in the interaction with the Form... or just me $#!^ing up somewhere else 
In any case, sorry for the not so clean post, as I mentioned before, its 3 AM here [3:43 at exactly this moment] and the only thing that keeps me awake is Blink182. Also I think I got a ROOTkit again. Tomorrow if there won't be any reply I am going to clean this post a bit, I just wanted to get over with it for today and go to sleep "^^
I copied a source code from a tutorial and fixed it to work without errors, but now it just doesn't do what its supposed to.
It is a completely basic upload form, you can see my failing result [with all the debug messages] here: http://frozenarmageddon.orgfree.com/upl ... loads2.php
I replaced a lot of stuff that didn't work for some reason with much simpler stuff that worked, But because it is 3:30 AM here I accidentally deleted my copy of the tutorial's source, so I can't show you what it was before I changed it.
Source [Sorry it seems like it won't let me upload it.]:
Code: Select all
<html>
<body>
<form enctype="multipart/form-data" action="" method="post">
Choose a file: <input name="file_name" type="file" />
<input type="submit" value="Upload" name="submit" />
</form>
</body>
</html>
<?php
session_start();
echo "DEBUG: Season start <br/>"; //DEBUG MESSAGE!!
if(!isset($_POST['submit']))
{
echo "DEBUG: If submit <br/>"; //DEBUG MESSAGE!!
echo "";
}
else {
echo "DEBUG: Elese submit <br/>"; //DEBUG MESSAGE!!
$filename = $_FILES['file']['name'];
echo 'DEBUG: Variable <b><em>$filename</em></b> set to: '.$filename."<br/>"; //DEBUG MESSAGE!!
$filesize = $_FILES['file']['size'];
echo 'DEBUG: Variable <b><em>$filesize</em></b> set to: '.$filesize."<br/>"; //DEBUG MESSAGE!!
$tmpname_file = $_FILES['file']['tmp_name'];
echo 'DEBUG: Variable <b><em>$tmpname_file</em></b> set to: '.$tmpname_file."<br/>"; //DEBUG MESSAGE!!
if($filesize > ‘1000000?) {
echo "Way too big!!";
} else {
move_uploaded_file($tmpname_file, "..");
echo "Successful.<br /><b>URL: </b>http://frozenarmageddon.orgfree.com/uploads/".$filename."</textarea>";
}
}
?>
and it results in [Uploaded file called 124723746384.jpg]:
Code: Select all
DEBUG: Season start
DEBUG: Else submit
DEBUG: Variable $filename set to:
DEBUG: Variable $filesize set to:
DEBUG: Variable $tmpname_file set to:
Successful.
URL: http://frozenarmageddon.orgfree.com/uploads/
In any case, sorry for the not so clean post, as I mentioned before, its 3 AM here [3:43 at exactly this moment] and the only thing that keeps me awake is Blink182. Also I think I got a ROOTkit again. Tomorrow if there won't be any reply I am going to clean this post a bit, I just wanted to get over with it for today and go to sleep "^^