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
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

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.