Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

pdf upload

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

pdf upload

Postby msj29aa » Wed Jun 22, 2011 1:37 pm

hey guys.

Im having problem uploading PDF files to my server. .txt is no problem.

my php looks like this:

<?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("upload1/" . $_FILES["file"]["name"]))
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload1/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload1/" . $_FILES["file"]["name"];
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload1/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload1/" . $_FILES["file"]["name"];
}
}

?>


please help! :)
msj29aa
New php-forum User
New php-forum User
 
Posts: 1
Joined: Wed Jun 22, 2011 1:33 pm

Re: pdf upload

Postby Nullsig » Thu Jun 23, 2011 4:12 am

In your form that allows the user to select the file to upload there should be a field:

Code: Select all
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />


This one maxes the file size to 100KB. PDFs depending on content and compression, are notoriously large compared to plain text.

The is probably the reason for your issue.
User avatar
Nullsig
php-forum Fan User
php-forum Fan User
 
Posts: 981
Joined: Thu Feb 17, 2011 6:52 am
Location: Racine, WI


Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 0 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.