Jump to content

Search the Community

Showing results for tags 'uploading images'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hello I have written the following code to update Images that are stored in Files. The code is working perfectly when I am using it to Upload images, but when I use it to Update Images, it is giving me 'Invalid file' error message. It is getting problem in the first 'if' statement and directly going to its else statement message 'Invalid File'. Kindly check it and guide me. Thanks <?php var_dump($_REQUEST); session_start(); error_reporting(E_PARSE); if (isset ($_SESSION['username']) ) { //echo "<div id='nav'"; echo "<ul><hr> <li><a href='insert_product.php' >Add Product | </a></li> <li><a href='add_category.php'> Add Category </a></li> <li><a href='sub_categories.php'> Add Sub-Category </a></li> <li><a href = 'view_products.php' >View All Products</a> </li> <li><a href = 'all_categories.php' >View All Categories</a> </li> <li><a href='view_all_sub_categories.php'>View All Sub Categories</a></li> </ul></hr>"; include 'connect.php'; $category_id= $_GET['category_id']; $query= "select * from category where category_id= $category_id"; $query_run= mysql_query($query); $fetch= mysql_fetch_array($query_run); $name= $fetch['name']; echo " <form action='update_category.php?category_id=$category_id' method='POST' > <table border=1> <tr><td> Category Name:</td><td><input type='text' name='category' value='$name' /> </td></tr> <tr><td> Image1:</td><td> <input type='file' name= 'image' > </td></tr> <tr><td> <input type='submit' value='Update' /> </td></tr> </form> </table> "; echo "<form action='delete_category.php?category_id=$category_id' method='POST'> <input type='submit' value='Delete'> </form> "; if (isset($_POST['category']) ) { $category_name = $_POST['category']; $query_update="UPDATE category SET name = '$category_name' WHERE category_id =$category_id "; if (mysql_query($query_update)) { echo "Records updated"; } else { echo mysql_error(); } /*------------------- IMAGE QUERY --------------------*/ $allowedExts = array("gif", "jpeg", "jpg", "png"); $extension = end(explode(".", $_FILES["image"]["name"])); if ((($_FILES["image"]["type"] == "image/gif") || ($_FILES["image"]["type"] == "image/jpeg") || ($_FILES["image"]["type"] == "image/jpg") || ($_FILES["image"]["type"] == "image/pjpeg") || ($_FILES["image"]["type"] == "image/x-png") || ($_FILES["image"]["type"] == "image/png")) //&& ($_FILES["file"]["size"] < 200000) && in_array($extension, $allowedExts)) { if ($_FILES["image"]["error"] > 0) { echo "Return Code: " . $_FILES["image"]["error"] . "<br>"; } else { echo "Upload: " . $_FILES["image"]["name"] . "<br>"; echo "Type: " . $_FILES["image"]["type"] . "<br>"; echo "Size: " . ($_FILES["image"]["size"] / 200000) . " kB<br>"; $image_name= $_FILES["image"]["name"]; $random_name= rand().$_FILES["image"]["name"]; $path= move_uploaded_file($_FILES["image"]["tmp_name"], "upload/categories/" . $random_name); $folder="upload/categories/" .$random_name; echo "Stored in: "."upload/categories/". $random_name; echo $sql= "update category_images set name='$image_name' , location='$folder' where category_id= $category_id "; $result = mysql_query($sql); if ($result) { echo "successfull"; } else { echo mysql_error(); } } } else { echo "Invalid file". $_FILES["image"]["error"]; } /*----------------- IMAGE QUERY END ------------------*/ } /* echo $sql= "update category_images set name='$image_name' , location='$folder' where category_id= $category_id "; */ } else { echo "You Must need to Log in to Visit this Page"; } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.