Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Allowing types of images for upload
Old 11-04-2008, 06:26 PM Allowing types of images for upload
GamingFreak's Avatar
Super Talker

Posts: 124
Name: Chris
Location: www.DecayedAds.com
Trades: 0
Hey,

I am having troubles allowing other image types to be allowed for upload on my site.
(www.YouHost.vndv.com)

Only type that can be uploaded right now is .GIF. Can anyone tell me what is wrong with the coding for it now allowing others?

Heres my code for the upload:
PHP Code:
<?php
if ((($_FILES["file"]["type"] == "image/gif")
|| (
$_FILES["file"]["type"] == "image/jpeg")
|| (
$_FILES["file"]["type"] == "image/bmp")
|| (
$_FILES["file"]["type"] == "image/png")
|| (
$_FILES["file"]["type"] == "image/jpg")
|| (
$_FILES["file"]["type"] == "image/pjpeg"))
&& (
$_FILES["file"]["size"] < 20000))
  {
  if (
$_FILES["file"]["error"] > 0)
    {
    echo 
"Return Code: " $_FILES["file"]["error"] . "<br />";
    }
  else
    {
    echo 
"Upload: " $_FILES["file"]["name"] . "<br />";
    echo 
"Type: " $_FILES["file"]["type"] . "<br />";
    echo 
"Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
    echo 
"Temp file: " $_FILES["file"]["tmp_name"] . "<br />";    if (file_exists("upload/" $_FILES["file"]["name"]))
      {
      echo 
$_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      
move_uploaded_file($_FILES["file"]["tmp_name"],
      
"uploads/" $_FILES["file"]["name"]);
      echo 
"URL: " "www.YouHost.vndv.com/uploads/" $_FILES["file"]["name"];
      }
    }
  }
else
  {
  echo 
"Sorry, an error occurred. Your File was either a format that we do not currently host or the file was larger than 20,000kb.";
  }
?>
__________________
FREE LINK DIRECTORY!
Please login or register to view this content. Registration is FREE
GamingFreak is offline
Reply With Quote
View Public Profile Visit GamingFreak's homepage!
 
 
Register now for full access!
Old 11-04-2008, 10:47 PM Re: Allowing types of images for upload
rezzy's Avatar
Super Talker

Posts: 115
Location: in the interwebz
Trades: 0
i believe using the || is creating the problem. I believe that the || will approve any image as long as it matches those types listed above. So, you should remove the other entries.

Because the section is checking whether it matches one of those data types, once it has it checks size. Removing those unwanted datatypes will solve the problem.
__________________

Please login or register to view this content. Registration is FREE

Resnodesigns
rezzy is offline
Reply With Quote
View Public Profile
 
Old 11-05-2008, 06:02 PM Re: Allowing types of images for upload
GamingFreak's Avatar
Super Talker

Posts: 124
Name: Chris
Location: www.DecayedAds.com
Trades: 0
I took out what you said and then it gave me an error and then i put them back in and then it worked. But said i tried to upload the wrong type. Only image I can upload is GIF, how I make it for all images. If I take off the image restriction, people can upload anything and thats a security risk.
__________________
FREE LINK DIRECTORY!
Please login or register to view this content. Registration is FREE
GamingFreak is offline
Reply With Quote
View Public Profile Visit GamingFreak's homepage!
 
Old 11-05-2008, 07:38 PM Re: Allowing types of images for upload
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
This ($_FILES["file"]["size"] < 20000) is file size under 20000 bytes not Kb. Your average jpeg will be in excess of 19kb
maxxximus is offline
Reply With Quote
View Public Profile
 
Old 11-05-2008, 08:48 PM Re: Allowing types of images for upload
GamingFreak's Avatar
Super Talker

Posts: 124
Name: Chris
Location: www.DecayedAds.com
Trades: 0
So what should I put in the size spot? I set it higher and it now works. Thanks!

P.S. I thought your avatar was a bug on my screen and i tried to kill it ^_^
__________________
FREE LINK DIRECTORY!
Please login or register to view this content. Registration is FREE

Last edited by GamingFreak; 11-05-2008 at 09:14 PM..
GamingFreak is offline
Reply With Quote
View Public Profile Visit GamingFreak's homepage!
 
Old 11-05-2008, 10:10 PM Re: Allowing types of images for upload
rezzy's Avatar
Super Talker

Posts: 115
Location: in the interwebz
Trades: 0
Quote:
Originally Posted by GamingFreak View Post
So what should I put in the size spot? I set it higher and it now works. Thanks!

P.S. I thought your avatar was a bug on my screen and i tried to kill it ^_^
me too... i miss read what you requested!

I thought you wanted on gif to be an option. LOL
__________________

Please login or register to view this content. Registration is FREE

Resnodesigns
rezzy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Allowing types of images for upload
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28137 seconds with 12 queries