Uploading

Hello phphelp.com,

After being a passive user for a while, I have a problem of my own I hope you can help me with.

Background:

For my parents small company I build a website. On this website I made a login page for employees.

What I want to do:

I want employees to be able to upload a pdf file in the secure section of the website. It should then be able to offer this pdf file on the website for my visitors to watch/dowload.

What I use:

A standard upload form in my html:

<form action="uploadfolder.php" method="post" enctype="multipart/form-data">

        File: <input type="file" name="upload">
        <input type="submit" name="submit" value="Upload folder">

</form>

The uploadfolder.php file:
[php]

<?php if ($_POST['submit']) { $name = $_FILES['upload']['name']; $temp = $_FILES['upload']['tmp_name']; $type = $_FILES['upload']['type']; $size = $_FILES['upload']['size']; if ($type == "application/pdf") { if ($size < 1000000) { move_uploaded_file($temp, "folders/$name"); } else { echo "File too big
} } else { echo "This is not a PDF file"; } } else { header('location: beheer.php'); } ?>

[/php]

When I try this code using localhost it works like a charm. But when I try this on my webserver it doesn’t.

My question:

How do I make this code work online? How do I connect to my webserver?

I hope you can help me out here, if you need more information I would be happy to give it to you.

Kind regards,

Erasia

Do not be scared to echo print print_var() any thing out they are there to help you, if you do not know how to use them learn they will help you out a lot in debugging a script.
put at top of php page
[php]print_r($_FILES[‘upload’]);[/php]

To start with

try changing
[php]echo "File too big
[/php]
to this
[php]echo “File too big
”;[/php]

Then try to see if there is a path problem
[php]
if(file_exists(‘folders’) && is_dir(‘folders’)){
move_uploaded_file($temp, “folders/”.$name);
echo ‘folders exists’;
}else{echo ‘no folder called folders’; }[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service