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
https://forums.phpfreaks.com/topic/236255-newbie-php/
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
https://forums.phpfreaks.com/topic/236255-newbie-php/#findComment-1214665
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
https://forums.phpfreaks.com/topic/236255-newbie-php/#findComment-1214692
Share on other sites

Well I found an article of sorts about this and made changes to

file_uploads

upload_max_filesize

max_input_time

memory_limit

max_execution_time

post_max_size

 

And now my uploads are working on 26M files hope this helps someone else.

Heres the link:

http://www.radinks.com/upload/config.php

Link to comment
https://forums.phpfreaks.com/topic/236255-newbie-php/#findComment-1215574
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.