File Size image upload problem PHP
Posted: Wed Apr 18, 2007 10:46 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am facing some trouble with uploadign multiple image files to my website. Whenever i upload less than 5 mb of files. The files ar uploaded successfully and are displayed with their thumbnails, etc. But when the total number of files size exceed to lets say 13 mb . There is error which comes up "Some unexpected error occured". Also sometimes it only displays a few files out of the total number of files uploaded. This error page also came up once. Warning: mkdir(): No such file or directory in /home/content/e/c/l/ecl123/html/photoalbum/upload.php on line 22
I am pasting the upload.php file here.Code: Select all
<?php
session_start();
include('../includes/PHP/functions_user.inc');
include('../includes/PHP/MySql.Class.php');
$DB = new sql();
function saveUploadedFiles()
{
$fileCount = $_POST ["FileCount"];
$galleryPath = "Gallery/";
//Iterate through uploaded data and save the original file, thumbnail, and description.
chdir($galleryPath);
mkdir($_GET['albumid'],0777);
chdir("../");
$galleryPath = $galleryPath.$_GET['albumid']."/";
$sitepath.=$_GET['albumid']."/";
for ($i = 1; $i <= $fileCount; $i++)
{
//Get source file and save it to disk.
$sourceFileField = "SourceFile_" . $i;
if (!$_FILES[$sourceFileField]['size'])
{
return;
}
$fileName = getfilename($_FILES[$sourceFileField]['name'],$galleryPath);
// move_uploaded_file($_FILES[$sourceFileField]['tmp_name'], $galleryPath . $fileName);
$photopath=$galleryPath . $fileName;
$thumbnail1Field = "Thumbnail1_" . $i;
$targetpath = "Gallery/";
move_uploaded_file($_FILES[$thumbnail1Field]["tmp_name"], $galleryPath.$fileName);
$sql_insert="insert into tblphoto set user_id=".$_SESSION['uid'].",album_id=".$_REQUEST['albumid'].",photo_path='".$photopath."'";
mysql_query($sql_insert) or die($sql_insert.mysql_error());
}
$lastid=mysql_insert_id();
$sql_update = "update tblphoto set cover_photo='1' where photo_id=".$lastid;
mysql_query($sql_update);
}
//This method verifies whether file with such name already exists
//and if so, construct safe filename name (to avoid collision).
function getfilename($fileName,$galleryPath)
{
// global $absGalleryPath;
$newFileName = $fileName;
$j = 1;
while (file_exists($galleryPath . $newFileName))
{
$newFileName = $j . "_" . $fileName;
$j = $j + 1;
}
return trim($newFileName);
}
saveUploadedFiles();
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]