473,378 Members | 1,447 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,378 software developers and data experts.

Php extension error

Hey guys i get something im not suppose to get when i run this script. The problem is when i select a jpg picture it still says :FILE MUST Be jpg/jpeg ..im running this on localhost php ver 5.3.8. Would appreciate if u could help god bless u

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $name = $_FILES['file']['name'];
  4. $type = $_FILES['file']['type'];
  5. $extension = strtolower(substr($name , strpos($name , '.'))+ 1 );
  6. $tmp_name =$_FILES['file']['tmp_name'];
  7.  
  8.  
  9.  
  10. if(isset($name)){
  11.  if(!empty($name)){
  12.  
  13.    if(($extension=='jpg' or $extension=='jpeg')&& $type=='image/jpeg'){
  14.  
  15.       $location = 'uploads/';
  16.  
  17.     if(move_uploaded_file($tmp_name , $location.$name)) {
  18.        echo 'DONE';
  19.     }else{
  20.        echo "ERROR";
  21.     }
  22.    }else{
  23.        echo 'FILE  MUST Be jpg/jpeg';
  24.     }
  25.    }else {
  26.       echo 'PLZ SELECT A FILE';
  27.    }
  28.  }
  29.  
  30.  
  31. ?>
  32.  
  33. <form action='uploadextension.php' method="POST" enctype="multipart/form-data">
  34.   <input type="file"  name ="file"><br><br>
  35.   <input type="submit" value='UPLOAD'>
  36. </form>
Dec 16 '11 #1

✓ answered by johny10151981

look at this line:
Expand|Select|Wrap|Line Numbers
  1. //strtolower(substr($name , strpos($name , '.'))+ 1 );
  2. //substr($name , strpos($name , '.'))+ 1 //what does it return? probably zero but not your string.
  3.  
  4. //your line would be
  5. strtolower(substr($name , strpos($name , '.')+1));
  6.  

2 1732
johny10151981
1,059 1GB
look at this line:
Expand|Select|Wrap|Line Numbers
  1. //strtolower(substr($name , strpos($name , '.'))+ 1 );
  2. //substr($name , strpos($name , '.'))+ 1 //what does it return? probably zero but not your string.
  3.  
  4. //your line would be
  5. strtolower(substr($name , strpos($name , '.')+1));
  6.  
Dec 17 '11 #2
ya that solved it thks bro u rock!
Dec 22 '11 #3

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
0
by: yzzzzz | last post by:
Hi, I am compiling PHP 5.0.2 myself with MySQL support. I did a ./configure --with-mysqli=/usr/local/mysql/bin/mysql_config (see end of post for complete configure) Note: I also have...
8
by: Russell E. Owen | last post by:
I'm writing a C extension for numarray and am puzzled about the idiom for error handling. The documentation seems to say one should always decref an array after calling NA_InputArray, etc., to...
5
by: Jeffry van de Vuurst | last post by:
Hi, I'm working on an xml schema and I'm running into some problems relating substitutionGroups and extensions. This xsd validates fine: There are three elements and three complex types and...
1
by: David C. allen | last post by:
I have created a simple Client-side SOAP Extension for a webclass that I have. When I apply the extension attribute to the the calling function in the proxy class I get an error 'Value cannot be...
2
by: Steve Y. | last post by:
My Environment ..Net SDK 1.1 on remote Win2k Server Connecting with VS 2003 via FrontPage Extension Error "The web server reported the following error when attempting to create o open the Web...
2
by: cordata5 | last post by:
Hi all, I finally figured out how to utilize the soapextension for encrypting portions of my xml file. However I want to encrypt the header going from the client web page to the server side web...
4
by: Andy Baxter | last post by:
hello, I'm using the php4-mysql module with php4 under debian linux (sarge). I have a script, schedule.php, which runs fine when I invoke it from the command line, but fails with the error: ...
0
by: Benzari.Alex | last post by:
What I want to do is use the FileInfo module as described in PHP Architect's guide to security I installed the extension under linux and it works just fine... and i tried to install it on my...
0
by: rautsmita | last post by:
hello friends , i am using to jdk6 and JAXB2.0, i have geomtry.xsd file i am trying to compile this file using jaxb but i got some error i.e.The particle of the type is not a valid restriction of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.