Upload file on php-5.2.2-3
Moderator: General Moderators
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Upload file on php-5.2.2-3
Can anybody suggest the code to upload a file maximum size could be 2 gb.
Re: Upload file on php-5.2.2-3
Just do a google search on PHP file uploads and you'll find quite a few tutorials on this.
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
I m writing the script everything is shown fine that its written now what should I do I m not getting the file uploaded on the upload folder.
What reasons are probable can you plz help me?
What reasons are probable can you plz help me?
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
Create an Upload-File Form
Create The Upload Script
Everything is fine only file is not visible in the upload folder, I guess it is not uploaded..
Code: Select all
<html>
<body>
<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="submit" value="Submit" />
</form>
</body>
</html>Code: Select all
<?php
if ($_FILES["file"]["type"] != "image/exe" )
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
Re: Upload file on php-5.2.2-3
I don't recall there being a mime type "image/exe". What type of image are you uploading?
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
If Change the code to this then also not working.
Code: Select all
<?php
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br />";
echo "Type: " . $_FILES["file"]["type"] . "<br />";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
?>
Re: Upload file on php-5.2.2-3
To say it is not working does not help any of us help you. We need detailed information such as the errors you are getting. Help us help you.
Re: Upload file on php-5.2.2-3
To say it is not working does not help any of us help you. We need detailed information such as the errors you are getting. Help us help you.
Re: Upload file on php-5.2.2-3
Back up a minute here, I don't think your going to [reliably] be able to post 2gb files via a form. I would look into alternatives, such as creating a write only ftp folder.
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
Plz help me to find out the errors i m not getting any error, I am using Linux with apache is the any need for granting with chmod, if so tell me what to do or tell me how to find out exactly the error.
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
Ok if not possible for 2 gb then tell me how much is possible and do that only for me .
Re: Upload file on php-5.2.2-3
Can you say what is being uploaded?
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
I want To Upload Any Kind of File
Here is what I am Getting With the Code.
Output as:
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => kaffeine.desktop
[type] => application/x-desktop
[tmp_name] => /tmp/phpv1V8cy
[error] => 0
[size] => 2921
)
)
Here is what I am Getting With the Code.
Code: Select all
<?php
// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
// of $_FILES.
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Possible file upload attack!\n";
}
echo 'Here is some more debugging info:';
print_r($_FILES);
print "</pre>";
?>
Possible file upload attack!
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => kaffeine.desktop
[type] => application/x-desktop
[tmp_name] => /tmp/phpv1V8cy
[error] => 0
[size] => 2921
)
)
Re: Upload file on php-5.2.2-3
Well move_uploaded_file is returning false.
I'd check to make sure that your $uploaddir has write permissions enabled for the apache user.
I'd check to make sure that your $uploaddir has write permissions enabled for the apache user.
-
kapil1089theking
- Forum Commoner
- Posts: 46
- Joined: Wed May 28, 2008 1:51 pm
- Location: Kolkata, India
- Contact:
Re: Upload file on php-5.2.2-3
How Can I modify or see The Write permission for Apache User?