# Upload Problem

**URL:** <https://forum.kirupa.com/t/upload-problem/222368>\
**Category:** programming\
**Created:** [April 12, 2007, 7:12pm UTC](https://forum.kirupa.com/t/upload-problem/222368 "2007-04-12T19:12:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![1219](https://avatars.discourse-cdn.com/v4/letter/1/f08c70/32.png) [@1219](https://forum.kirupa.com/u/1219)\
**Post date:** [April 12, 2007, 7:12pm UTC](https://forum.kirupa.com/t/upload-problem/222368/1 "2007-04-12T19:12:53Z")

</div>

I want to be able to upload at least a maximum of 50MB here is my PHP code:

```
    &lt;?php
    $MAX_SIZE = 90000000;                      
    $FILE_EXTS = array('.jpg','.gif','.png','.psd','.eps','.ai','.exe','.zip','.tar','.sit','.txt','.doc','.pdf','.rtf','.ste','.stc'); 
    $DELETABLE = true;                               
    $site_name = $_SERVER['HTTP_HOST'];
    $url_dir = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
    $url_this = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
    $upload_dir = "1/";
    $upload_url = $url_dir."/1/";
    $message ="";
    if (!is_dir("1/")) {
    if (!mkdir($upload_dir))
    die ("upload_files directory doesn't exist and creation failed");
    if (!chmod($upload_dir,0777))
    die ("change permission to 777 failed.");
    }
    if ($_REQUEST[del] && $DELETABLE) {
    $resource = fopen("../logs/upload.txt","a");
    fwrite($resource,gmdate("m.d.Y h:i A \E\S\T", time() -14500)." $_SERVER[REMOTE_ADDR] - Delete "."$_REQUEST[del]

```

“);  
fclose($resource);  
if (strpos($\_REQUEST[del],”/.")\>0);  
else if (strpos($\_REQUEST[del],$upload\_dir) === true);  
else if (substr($\_REQUEST[del],0,2)==$upload\_dir) {  
unlink($\_REQUEST[del]);  
print “\<script\>window.location.href=’$url\_this?message=Deleted successfully.’\</script\>”;  
}  
}  
else if ($\_FILES[‘UserFile’]) {  
$resource = fopen("…/logs/upload.txt",“a”);  
fwrite($resource,gmdate(“m.d.Y h:i A \E\S\T”, time() -14500)." $\_SERVER[REMOTE\_ADDR] - Upload " .$\_FILES[‘UserFile’][‘name’]."  
“);  
fclose($resource);  
$file\_type = $\_FILES[‘UserFile’][‘type’];  
$file\_name = $\_FILES[‘UserFile’][‘name’];  
$file\_ext = strtolower(substr($file\_name,strrpos($file\_name,”.")));  
if ( $\_FILES[‘UserFile’][‘size’] \> $MAX\_SIZE)  
$message = “The file size is over 50MB.”;  
else if (!in\_array($file\_ext, $FILE\_EXTS))  
$message = “Sorry, this file is not allowed to be uploaded.”;  
else  
$message = do\_upload($upload\_dir, $upload\_url);  
print “\<script\>window.location.href=’$url\_this?message=$message’\</script\>”;  
}  
else if (!$\_FILES[‘UserFile’]);  
else  
$message = “Invalid file specified.”;  
$handle=opendir($upload\_dir);  
$filelist = “”;  
while ($file = readdir($handle)) {  
if(!is\_dir($file) && !is\_link($file)) {  
$filelist .= “\<li\>\<a href=’$upload\_dir$file’\>”.$file."";  
if ($DELETABLE)  
$filelist .= " - \<a href=’?del=$upload\_dir".urlencode($file)."’ title=‘Delete’\>x\</li\>";  
}  
}  
function do\_upload($upload\_dir, $upload\_url) {  
$temp\_name = $\_FILES[‘UserFile’][‘tmp\_name’];  
$file\_name = $\_FILES[‘UserFile’][‘name’];  
$file\_name = str\_replace("\","",$file\_name);  
$file\_name = str\_replace("’","",$file\_name);  
$file\_path = $upload\_dir.$file\_name;  
if ( $file\_name =="") {  
$message = “Invalid file name specified.”;  
return $message;  
}  
$result = move\_uploaded\_file($temp\_name, $file\_path);  
if (!chmod($file\_path,0777))  
$message = “Change permission to 777 failed.”;  
else  
$message = ($result)?“Uploaded successfully.” :“Something is wrong with uploading a file.”;  
return $message;  
}  
?\>

This is my PHP.INI file:

register\_globals = Off  
safe\_mode = On  
max\_execution\_time = 1600  
memory\_limit = 100M  
post\_max\_size = 100M  
upload\_max\_filesize = 100M

Any clues about why it will upload less than 2MB but nothing more?
