Jump to content

[SOLVED] help with upload script


lewis987

Recommended Posts

ive got an upload script and it doesnt want to upload a file over a certain size, although the file size and file type is within the regualtions,

code:
<?php
// thanks page after succesfull upload.
$tpage = "thanks.htm";
// error page if size exceeded from allowed size.
$size= "size.htm";
// error page if extension is not correct.
$extpage = "extpage.htm";
// error page if file already exists on server.
$exist = "exist.htm";
// error page if no file has been selected.
$notselect = "notselect.htm";
// write yes if you want to limit file extensions to be uploaded
// And write no if you donot want to limit the files to be uploaded.
$elimit = "no";
// Write file types which u want to allow.
$lext = array(".gif",".jpg",".zip",".iso",".7z",".rar");

// check if file has been selected otherwise forwad to erro2.htm
$file_tmp = $_FILES['file']['tmp_name'];
if (!is_uploaded_file($file_tmp)){
          echo header("Location: $notselect");
          exit();
          }
         
//write the maximum size of file in bytes.
if (($_FILES["file"]["size"] <= 10000000000000000)) {
//check for file extension if file extension is not correct forwad to extpage.htm
  $ext = strrchr($file_name,'.');
          if (($elimit == "yes") && (!in_array(strtolower($ext),$lext))) {
              echo header("Location: $extpage");
              exit();
          }
// following string holds file name.   
$fname = $_FILES['file']['name'];
// following string replaces spaces in file name with underscore(_)
$fname = str_replace(' ', '_', $fname);

//Now if every thing is OK following function will upload the file.
// change uploads with your directory in which u want to store the files
  if (file_exists("uploads/" . $_FILES["file"]["name"])) {
    echo header("Location: $exist");
  } else {
    move_uploaded_file($_FILES["file"]["tmp_name"],
    "uploads/" ."$fname" ); 
// Thanks page if file uploaded successfully   
    header("Location: $tpage");       
  }

} else
// error page if file size exceded from allowed file size.
  header("Location: $size");
?>

any help will be apperciated

--lewis
Link to comment
https://forums.phpfreaks.com/topic/18182-solved-help-with-upload-script/
Share on other sites

lol, oops, i found out the file i uploaded was 1 mb, not 150k and im needing the script to upload files as large as 2GB and i cant seem to work it out why its not wanting to upload nothing bigger the 1mb, ive even tried a 5mb and the same output

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.