Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
script not uploading bigger files but works for smaller files
Old 10-17-2009, 05:26 PM script not uploading bigger files but works for smaller files
Skilled Talker

Posts: 54
Trades: 0
Below is the script i wrote to upload my files to my webserver download director. it does work for smaller files but when a file of about 50mb is to be upload it does not work and shows blank page. the error messages i set to show in case of the script failure also does not show. i set the value of the post_max_size in php.ini file to 100M but to no avail.please help.
Code:
<form action="../cms/add.php" method="post" name="form3" id="form3" enctype="multipart/form-data">
  <table align="center">
    <tr valign="baseline">
      <td nowrap="nowrap" align="right">Description:</td>
      <td><input type="text" name="description" value="" size="32" /></td>
    </tr>
   
    <tr valign="baseline">
      <td nowrap="nowrap" align="right" valign="top">location:</td>
      <td><input type="file" name="filepath" size="32"/>
      </td>
    </tr>
    <tr valign="baseline">
     
      <td align="center" colspan="2"><input type="submit" value="ADD" /></td>
    </tr>
  </table>
</form>
PHP Code:
<?php require_once('Connections/sql1.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}
function 
calc($size) {
    
$kb=1024;
    
$mb=1048576;
    
$gb=1073741824;
    
$tb=1099511627776;
    if(!
$size)
      return 
'0 B';
    elseif(
$size<$kb)
      return 
$size.' B';
    elseif(
$size<$mb)
      return (
round($size/$kb2).' KB');
    elseif(
$size<$gb)
      return (
round($size/$mb2).' MB');
    elseif(
$size<$tb)
      return (
round($size/$gb2).' GB');
    else
      return (
round($size/$tb2).' TB');
  }
if (
$_FILES){
        
error_reporting(E_ALL E_NOTICE);
    
// Doublecheck that we really had a file:
    
if(!$_FILES['filepath']['size'])
    {
       echo 
"No actual was uploaded";
       exit();
    }
    else {
        
// Determine the filename to which we want to save this file:
        
$newname "..\\downloads\\".basename($_FILES['filepath']['name']);
        
$filepath=    "downloads/".basename($_FILES['filepath']['name']);    
        
$filetype=$_FILES['filepath']['type'];
        
$filesize=$_FILES['filepath']['size'];
        
$filesizecalc($filesize);
        
// Attempt to move the uploaded file to it's new home:
       /* if (!(move_uploaded_file($_FILES['filepath']['tmp_name'],
                $newname))) {
            echo "<p>ERROR:  A problem occurred during file upload!</p>\n";
            exit();
        } else {*/
            // It worked!
            
$_POST['filepath']=$filepath;
            if(!
get_magic_quotes_gpc())
            {
            
$_POST['filepath']=addslashes($filepath);
            }
            
  
$insertSQL sprintf("INSERT INTO downloads (description,type,size,url) VALUES (%s, %s,%s,%s)",
                       
GetSQLValueString($_POST['description'], "text"),
                       
GetSQLValueString($filetype"text"),
                       
GetSQLValueString($filesize"text"),
                       
GetSQLValueString($_POST['filepath'], "text"));
  
mysql_select_db($database_sql1$sql1);
  
$Result1 mysql_query($insertSQL$sql1) or die(mysql_error());

   echo 
"<p>Done!  The file has been saved as: {$newname}</p>\n";
       
// }
    
}
}
kani alavi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-17-2009, 06:08 PM Re: script not uploading bigger files but works for smaller files
Defies a Status

Posts: 1,605
Trades: 0
Are you on a dedicated? Most likely you won't be able to do this on shared.

There are actually 3 things you have to adjust to get php to handle the larger files. post_max_size is one and the other two are memory related but I can't recall the names without looking it up.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 10-19-2009, 08:08 AM Re: script not uploading bigger files but works for smaller files
Ultra Talker

Posts: 339
Trades: 0
You should also check max script execution time as well. Maybe it's very low and your script just times out?
__________________
Daniel, Helpdesk Leader

Please login or register to view this content. Registration is FREE
- First class web hosting services.

Please login or register to view this content. Registration is FREE
- Provide unlimited disk space and bandwidth!
Hosting24 is offline
Reply With Quote
View Public Profile
 
Old 10-21-2009, 12:28 PM Re: script not uploading bigger files but works for smaller files
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
First of all look into your php error log, it will most likely tell you the reason.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 10-21-2009, 06:44 PM Re: script not uploading bigger files but works for smaller files
orionoreo's Avatar
Ultra Talker

Posts: 335
Name: Jerry
Trades: 0
like everybody has said


you'll probably have the set the php limit in the ini or the file itself if it's timing out
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
orionoreo is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to script not uploading bigger files but works for smaller files
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21648 seconds with 12 queries