Jump to content

[SOLVED] No error :S


LiamProductions

Recommended Posts

Hey.

 

I've made a simple upload script... and its not giving me any errors or uploading the file or even telling me the file name

 

<?php

if($_FILES['file']['size'] < 20000) {
if($_FILES['file']['error'] > 0) {
echo "We have found a error: " . $_FILES['file']['error'] . "<br />";
}
else {
echo "File: " . $_FILES['file']['name'] . "<br />";
echo "Type: " . $_FILES['file']['type'] . "<br />";
echo "Size: " . $_FILES['file']['size'] . "<br />";

if(file_exists("upload" . $_FILES['file']['name'])) {
echo "Sorry, " . $_FILES['file']['name'] . "already exists. ";
}
else {
move_uploaded_file($_FILES['file']['tmp_name'],
"upload/" . $_FILES['file']['name']);
echo "Stored in: http://www.liam-monks.com/upload/" . $_FILES['file']['name'];
}
}
}
else {
echo "Invalid File!";
}


?>

 

 

I don't see the error anywhere and its providing no error:

 

Full page result:

File:

Type:

Size:

Stored in: http://www.liam-monks.com/upload/

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/
Share on other sites

try this.

 

<?php
echo "<pre>";print_r($_FILES);
if($_FILES['file']['size'] < 20000)
{
if($_FILES['file']['error'] > 0)
{
	echo "We have found a error: " . $_FILES['file']['error'] . "<br />";
}else{
	echo "File: " . $_FILES['file']['name'] . "<br />";
	echo "Type: " . $_FILES['file']['type'] . "<br />";
	echo "Size: " . $_FILES['file']['size'] . "<br />";

	if(file_exists("upload" . $_FILES['file']['name']))
	{
		echo "Sorry, " . $_FILES['file']['name'] . "already exists. ";
	}else{
		move_uploaded_file($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']);
		echo "Stored in: http://www.liam-monks.com/upload/" . $_FILES['file']['name'];
	}
}
}else{
echo "Invalid File!";
}

?>

 

whats returned

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-327999
Share on other sites

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="PHP Designer 2007">

<title>Untitled 2</title>
</head>

<body>

<form method="post" action="uploadfinish.php">
File: <input type="file" name="file">
<input type="submit" value="Upload!">

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328014
Share on other sites

change

<form method="post" action="uploadfinish.php">
File: <input type="file" name="file">
<input type="submit" value="Upload!">

 

to

 

<form method="post" action="uploadfinish.php" enctype="multipart/form-data">
File: <input type="file" name="file">
<input type="submit" value="Upload!">
</form>

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328021
Share on other sites

Sure...

 

upload.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="PHP Designer 2007">

<title>Untitled 2</title>
</head>

<body>

<form method="post" action="uploadfinish.php" enctype="multipart/form-data">
File: <input type="file" name="file">
<input type="submit" value="Upload!">
</form>

</body>
</html>

 

AND...

 

uploadfinish.php

<?php

echo "<pre>";print_r($_FILES);

if($_FILES['file']['size'] < 20000)

{

if($_FILES['file']['error'] > 0)

{

echo "We have found a error: " . $_FILES['file']['error'] . "<br />";

}else{

echo "File: " . $_FILES['file']['name'] . "<br />";

echo "Type: " . $_FILES['file']['type'] . "<br />";

echo "Size: " . $_FILES['file']['size'] . "<br />";

 

if(file_exists("upload" . $_FILES['file']['name']))

{

echo "Sorry, " . $_FILES['file']['name'] . "already exists. ";

}else{

move_uploaded_file($_FILES['file']['tmp_name'], "upload/" . $_FILES['file']['name']);

echo "Stored in: http://www.liam-monks.com/upload/" . $_FILES['file']['name'];

}

}

}else{

echo "Invalid File!";

}

 

?>

 

and the result of the page is:

 

Array
(
    [file] => Array
        (
            [name] => tgpamandabynes.jpg
            [type] => image/jpeg
            [tmp_name] => /tmp/phpr3RLIq
            [error] => 0
            [size] => 28375
        )

)
Invalid File!

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328088
Share on other sites

file is too big

if($_FILES['file']['size'] < 20000)

 

    [file] => Array

        (

            [name] => tgpamandabynes.jpg

            [type] => image/jpeg

            [tmp_name] => /tmp/phpr3RLIq

            [error] => 0

            => 28375

        )

 

 

 

change to

if($_FILES['file']['size'] < 2000000)

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328090
Share on other sites

This is the output now:

 

File: healthbar.png
Type: image/png
Size: 270


Warning:  move_uploaded_file(upload/healthbar.png) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/liam/public_html/uploadfinish.php on line 17



Warning:  move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpfOcFhM' to 'upload/healthbar.png' in /home/liam/public_html/uploadfinish.php on line 17

Stored in: http://www.liam-monks.com/upload/healthbar.png

 

 

Link to comment
https://forums.phpfreaks.com/topic/65678-solved-no-error-s/#findComment-328113
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.