Jump to content

Archived

This topic is now archived and is closed to further replies.

lewis987

[SOLVED] help with upload script

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

Share this post


Link to post
Share on other sites
make sure that the file you are trying to upload is not bigger than the max file size allowed in the php.ini file (default is 8M i believe)

If it is then you either have to change the setting or use ftp protocols.

Share this post


Link to post
Share on other sites
toonMariner ive changed the upload size in the pphp.ini file, but still i cant seem to upload any file bigger 150K and the default ion the php.ini file for uploads is 2M btw, if you can, please help, im very new to php

Share this post


Link to post
Share on other sites
what message does your script put out?

does it say successful but no file is there or does it say file is too big?

Share this post


Link to post
Share on other sites
it says that there was no file selected, try it if you want, http://82.413.137.80
it just doesnt want to work, it will upload a file at 1 mb, but not a file 20mb

its an apache server btw on windows

Share this post


Link to post
Share on other sites
You said it won't upload a 150k file? then you say it will upload a 1M file but not a 20M file?

If that is true you have answered your own question!!!!!

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
you are limited on the size of files you can upload via this method.

Have a look for a script to upload large files on google

Share this post


Link to post
Share on other sites
ok, i havent came accross a free one, have any suggestions?

Share this post


Link to post
Share on other sites
You might want to check out this page: [url=http://www.radinks.com/upload/config.php]http://www.radinks.com/upload/config.php[/url]

Share this post


Link to post
Share on other sites
thnaks, but what if i try upload a file with a dash (-) in its name, would it upload?

Share this post


Link to post
Share on other sites

×

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.