473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

problem while uploading

Hi,

I have a page for uploading pictures
I have limited the file uploaded to be jpg ( and other picture types) and size upto 2 MB.

Everything goes well, except when I give files larger than 8 MB (which is the post_max_size) it doesn't show any error, even if the file is of different type other than picture.

It doesn't display any messages, neither success nor failure.

How can I display error messages for those files ?

Thanks
Dec 30 '07 #1
2 1223
Markus
6,050 Expert 4TB
Uhm, do you have some if and else statements?

If you'd like to post the relevant code we could help :)
Dec 30 '07 #2
Yeah,
the code is
[PHP]<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data">
<br/><br/>
<table width=90% align="center">
<tr>
<td>Upload image:</td>
<td><input type="file" name="image"></td>
</tr>
<tr><td></t><td>
<input type="submit" name="upload" value=Upload>
</td>
</tr>
<tr><td></td><td>
<?php
$link=mysql_connect('localhost','user','user');
mysql_select_db('test');

$typeOK=FALSE;
$sizeOK=FALSE;
$loginid=$_SESSION['loginid'];
$permitted=array('image/jpeg','image/png','image/tiff','image/gif','image/pjpeg');
if (isset($_POST['upload']))
{

if ($_FILES['image']['name'])
{

foreach ($permitted as $type)
{
if ($_FILES['image']['type']==$type)
$typeOK=TRUE;
}

if ($_FILES['image']['size']<1000000 && $_FILES['image']['size']>0)
$sizeOK=TRUE;

if ($sizeOK && $typeOK)
{
define('UPLOAD_DIR', '/var/www/html/uploads/');
//remove spaces from uploaded file
$file=str_replace(' ','_',$_FILES['image']['name']);
$completepath=UPLOAD_DIR."$loginid/$file";

$date=date('Y-m-d');

$query="insert into pictures values('$completepath','$loginid','','$date')";
$result=mysql_query($query);
//if insert into database is successful
if ($result){

//make directory named after the name of user loginid if it doesn't already exist
if (!is_dir(UPLOAD_DIR.$loginid)) mkdir(UPLOAD_DIR.$loginid);
//move the uploaded file
if (move_uploaded_file($_FILES['image']['tmp_name'], $completepath))
print("<br/><font color=green>Uploaded file successfully to database");
else print ("<br/> Couldn't upload to server");
}
}
else { print ("<br/><font color=red>Upload Failed <br/>"); if (!$sizeOK) print("Size of file is out of the range"); else if (!$typeOK) print("This file type is not supported"); }
}
else print("<font color=red>No file selected");
}
?>
[/PHP]
Dec 30 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike | last post by:
Hi i have a problem in asp.ne i am uploading file to the server using htmlinput controls and every thing is o but i try to upload larger file to the server like more than 4 mb and about 10mb i got...
1
by: Jonathan | last post by:
Hi everyone, I have a problem with the file uploading in Asp.Net and I have read a lot on forums on this but never found an answer. Here is the problem: I know Asp.Net maximum Length for...
4
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the...
7
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user...
4
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a different problem in my application. In that I am uploading a folder that contain only images. Everything was done and was working fine too. When I executed the application using...
3
by: Carlos | last post by:
Hello Forum, I would appreciate it if you could recommend settings to use auto-vacuum in my version 7.4 database. I am uploading several thousands records in the database at a rate of ~1 second...
0
by: Ramakrishnan Nagarajan | last post by:
Hi, I am facing a problem in uploading Excel data to the Database. While uploading my code reads Excel Data using OleDbReader and store into a dataset by looping through the OleDbReader result...
7
by: jambroo | last post by:
Hello, We are currently having issues uploading files using PHP. It seems files below 8MB are uploaded fine, however files above 8.2MB cause the page to timeout or show a 'Cannot find server or...
3
ganesanji
by: ganesanji | last post by:
hi all, I have written a php coding for uploading a file to a specific folder or location in server which is a Linux server. I think the coding for file uploaing is correct. But it does not...
2
by: Bremanand | last post by:
Hi folks, i am working in C# , i have problem while uploading the file to FTP which has size around 4MB. The code which comes after the bold area is not executed.. here am...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.