Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6932541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:43:08+00:00 2026-05-27T11:43:08+00:00

I wonder whether someone could help me please. I have to admit I’m relatively

  • 0

I wonder whether someone could help me please.

I have to admit I’m relatively new to writing PHP so please bear with me.

Through articles I’ve read on the internet and some first class tutition from one @Marcio on this site, I’ve put together a script that allows users to save Image Files to a mySQL database.

I’ve now gone a little further by restricting the size of the file that can be uploaded, but I I’d like to add a warning message that tells why the file cannot be uploaded i.e. because it’s size is greater than the limit set.

I’ve made an attempt at this, as seen in the code below. But unfortunately I receive an error message stating that there is an unexpected ‘>’ which I know relates to the line I’ve added, but not sure how to code this another way.

Revised Cut Down Code

 <?php

   // This function makes usage of 
// $_GET, $_POST, etc... variables 
// completly safe in SQL queries 
function sql_safe($s) 
{ 
    if (get_magic_quotes_gpc()) 
        $s = stripslashes($s); 

    return mysql_real_escape_string($s); 
} 

// If user pressed submit in one of the forms 
if ($_SERVER['REQUEST_METHOD'] == 'POST') 
{ 
    if (!isset($_POST["action"])) 
    { 
        // cleaning title field 
        $title = trim(sql_safe($_POST['title'])); 

        if ($title == '') // if title is not set 
            $title = '(No title provided';// use (empty title) string 

        if (isset($_FILES['photo'])) 
        { 
            @list(, , $imtype, ) = getimagesize($_FILES['photo']['tmp_name']); 
            // Get image type. 
            // We use @ to omit errors 

            if ($imtype == 3) // cheking image type 
                $ext="png";   // to use it later in HTTP headers 
            elseif ($imtype == 2) 
                $ext="jpeg"; 
            elseif ($imtype == 1) 
                $ext="gif"; 
            else 
                $msg = 'Error: unknown file format'; 

            if($_FILES["fileupload"]["size"]/1024000 >= 10) // 10mb 
            {     
            $fileErrMsg = "<br />Your uploaded file size:<strong>[ ". $_FILES["fileupload"]["size"]/1024000  . " MB]</strong> is more than allowed 10MB Size.<br />";        

            } 

            if (!isset($msg)) // If there was no error 
            { 
                $data = file_get_contents($_FILES['photo']['tmp_name']); 
                $data = mysql_real_escape_string($data); 
                // Preparing data to be used in MySQL query 

                mysql_query("INSERT INTO {$table} 
                                SET ext='$ext', title='$title', 
                                    data='$data'"); 

                $msg = 'Success: Image Uploaded'; 
            } 
        } 

I just wondered whether someone could perhaps take a look at this and let me know what I’m doing wrong.

Many thanks and kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:43:09+00:00Added an answer on May 27, 2026 at 11:43 am

    You can use this

    if($_FILES["fileupload"]["size"]/1024000 >= 10) // 10mb
    {
        $fileErrMsg = "<br />Your uploaded file size:<strong>[ ". $_FILES["fileupload"]["size"]/1024000  . " MB]</strong> is more than allowed 10MB Size.<br />";   
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder whether someone could help me please. I have put together a form
I wonder whether someone could help me please. Through the use of some online
I wonder whether someone could help me please. I've been looking through this, and
I wonder whether someone could help me please. I've really got myself in a
I wonder whether someone could help me please. I'm using Image Uploader from Aurigma,
I wonder whether someone could help me please, From a tutorial I found online
I wonder whether someone can help me please. I have the following xml file
I wonder whether someone can help me please. I have a mySQL database which
I wonder whether someone could please help me. I'm trying to incorporate an 'filesize'
I wonder whether someone could help me please. I'm put together the following form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.