GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Any PHP gurus in the house? Can you help with simple task? (https://gfy.com/showthread.php?t=906406)

Pics Traffic 05-20-2009 09:12 PM

Any PHP gurus in the house? Can you help with simple task?
 
I have this script that uploads image and does insert entries in db. The upload field is for graphics only. Im trying to restict it to these types only:

$fileType=='image/jpg' ||
$fileType=='image/png' ||
$fileType=='image/gif'

How can I put in my script? Here's the little scripty I wrote.. I just need to add restrictions on upload types.

PHP Code:

<?php 

$target 
"images/"
$target $target basename$_FILES['photo']['name']); 

$VIDEOID=strip_tags($_POST['name']); 
$BANNER_URL=strip_tags($_POST['email']); 
$BANNER_NAME=strip_tags(($_FILES['photo']['name']));

mysql_connect("localhost""xxx""xxx") or die(mysql_error()) ; 
mysql_select_db("xxxx") or die(mysql_error()) ; 

mysql_query("INSERT INTO `banners` VALUES ('$VIDEOID', '$BANNER_URL', '$BANNER_NAME')") ; 

if(
move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 


echo 
"The file "basename$_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"

else { 

echo 
"Sorry, there was a problem uploading your file."

?>


Pics Traffic 05-20-2009 09:41 PM

figured it out. had a stupid typo.

nation-x 05-21-2009 04:42 AM

just a suggestion... if this upload is public you should do more than strip_tags to make it secure and it's always a good idea to escape text before you insert it.

check http://us3.php.net/mysql_real_escape_string


All times are GMT -7. The time now is 12:43 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123