Jump to content

Newbie PHP


jonstroh

Recommended Posts

I have used a tutorial to create an upload form for my website, it works fine until the file gets over 850 kb, how can I set it up so larg files 80 megs and up can be uploaded?

Here is the simple code I am using,form

 <form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden"  name="MAX_FILE_SIZE" value="100000000"  />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

PHP
<html>

Thanks 
<head>
<title>My First PHP Page</title>
</head>
<body>
<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

?>
</body>
</html>

Link to comment
Share on other sites

in php.ini  there are a settings you need to change (filesize that is).

;;;;;;;;;;;;;;;;

; File Uploads ;

;;;;;;;;;;;;;;;;

 

; Whether to allow HTTP file uploads.

; http://php.net/file-uploads

file_uploads = On

 

; Temporary directory for HTTP uploaded files (will use system default if not

; specified).

; http://php.net/upload-tmp-dir

upload_tmp_dir = "c:/wamp/tmp"

 

; Maximum allowed size for uploaded files.

; http://php.net/upload-max-filesize

upload_max_filesize = 2M

 

Although I am not sure if you can get to the php.ini or that your on a shared host. Nor do i know if uploading files of 800M is very stable.

 

But what you could try if you can't edit php.ini is the following

Put this above your script:

ini_set('upload_max_filesize', '800M');

Not sure if it works, but it's worth a try :)

Link to comment
Share on other sites

Thank You for your help I did edit the php.ini file on my server, and set it to 800M, that allowed me to upload a 6 meg file successfully, so then I zipped up the  database file(mdf) and it then was only 26 megs, but it failed. So I tried a 14 meg file and it failed also.

 

Both were zip files does that matter?

 

Are there any other settings I can change?

 

Here is the code I am using now

FormHTML

 <form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden"   />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>

PHP Code

<?php
$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}

?>

Link to comment
Share on other sites

When I tried to upload the mdf file without being zipped I get this error

 

404 - File or directory not found.

 

The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

 

Jon

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.