Old 02-09-2006   #1 (permalink)
Registered User
 
Join Date: Aug 2005
Posts: 15

PHP Uploading - File Size Errors

Hey guys,
I have a script that uploads MP3 files into a certain directory on my site... I use a pretty simple mothod and in order to play the mp3s, the script makes a m3u file and whatnot... which all works....

EXCEPT - when I upload files over somewhere in the vicinity of 2.5 mb. Everything works for file below that, but not over. It makes the m3u file, but when I go check in the folder, the mp3 does not appear to be there. Is there some sort of upload limit to PHP? If so, can I bypass it? Anyhow, here is the code...

Code:
<?
session_start();

if($_SESSION["online"] != "granted")	
	{
 		echo '<script>alert("You are not logged into WUC.");</script>';
		header( "Location: index.html");
	}

if(file_exists('upload/'.$_FILES['file']['name'])) 
	{
		echo '<script>alert("The file name already exists!");</script>';
		echo '<script>history.back(1);</script>';
	}
	else
	{

$uploadto = 'upload/';
$uploadfile = $uploadto . basename($_FILES['file']['name']);

if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
   
}

$filename =  $_FILES['file']['name']; 
$songurl = "upload/$filename";  

$prefirstnameofm3u = "$_POST[bandname]-$_POST[songtitle]";
$firstnameofm3u = addslashes($prefirstnameofm3u);
$secondnameofm3u = trim($firstnameofm3u);
$thirdnameofm3u = strtolower($secondnameofm3u);
$nameofm3u = str_replace(" ", "_", $thirdnameofm3u);

$mp3location = "http://www.loaded-designs.com/wuc/$songurl";


	$file = "upload/$nameofm3u.m3u"; 
     	$open = fopen($file, "w+"); 
     	fwrite($open, $mp3location); 
     	fclose($open); 

$table_name = "listen";

include("dbfactors.inc");

	$connection = mysql_connect("$host", "$db_user", "$db_password")
		or die(mysql_error());

	$db = @mysql_select_db($db_name, $connection) or die(mysql_error());

$sql = "INSERT INTO $table_name (bandname, songtitle, songurl, songhttp) VALUES ('$_POST[bandname]', '$_POST[songtitle]', '$file', '$songurl')";
$result = @mysql_query($sql,$connection) or die(mysql_error());

}

?>
ibanez270dx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 02-09-2006   #2 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

Yes there is a file upload limit in PHP. I have a link for you to check how to configure your setup to work with big files.

Howto optimize your PHP installation to handle large file uploads.
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 02-09-2006   #3 (permalink)
Sheep Worrier
 
Man1c M0g's Avatar
 
Join Date: Sep 2003
Location: Portsmouth, UK.
Posts: 4,073
Blog Entries: 14

Send a message via ICQ to Man1c M0g Send a message via MSN to Man1c M0g Send a message via Skype™ to Man1c M0g
Quote:
Originally Posted by Telos
Yes there is a file upload limit in PHP. I have a link for you to check how to configure your setup to work with big files.

Howto optimize your PHP installation to handle large file uploads.
If your file requires processing you may also want to increase the PHP script execution time maximum. Big operations often get swamped by routine stuff and may take longer than the default 60 seconds allowed.
__________________
Man1c M0g is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 02-10-2006   #4 (permalink)
Registered User
 
Join Date: Aug 2005
Posts: 15

wow thanks guys! Really useful stuff!

One more question though - when I upload a file with spaces in it, for example... "Queen - We Will Rock you.mp3", how can I rename that file without spaces or capital letters? It seems that my delete option doesn't work when there are spaces ... (it uses the unlink(thingtodelete); string function).

Thank guys, you're the best,
- Jeff
ibanez270dx is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old 02-10-2006   #5 (permalink)
Eternal Being
 
Join Date: Feb 2006
Location: Finland
Posts: 239

Code:
<?php strtolower(str_replace(" ", "_", $filename)); ?>
__________________
Telos is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.PSD File Size Question Pho3niX Adobe Photoshop 10 04-27-2006 06:50 PM
Reducing kb (size of file) w/o reducing size of image jasonchan483 Adobe Photoshop 5 11-18-2005 09:20 PM


All times are GMT +1. The time now is 06:50 AM.
Content Relevant URLs by vBSEO 3.2.0

Design & Content © BioRUST 2008 :: PRIVACY STATEMENT :: LEGAL INFORMATION :: ADVERTISING MEDIA KIT