Asday Posted July 12, 2007 Share Posted July 12, 2007 I've looked up substring on google, but I don't quite understand. Case: I want to disallow anything starting with "http://" I've got this far: if ($_FILES["file"]["name"] !== // something Link to comment https://forums.phpfreaks.com/topic/59624-solved-substring/ Share on other sites More sharing options...
Lumio Posted July 12, 2007 Share Posted July 12, 2007 What you're looking for is substr <?php $s = 'http://www.php.net'; if (substr($s, strlen('http://'))) { //code ... it starts with http:// ... so what to do? }else { //code ... it doesn't start with http:// ... so what to do? } ?> Link to comment https://forums.phpfreaks.com/topic/59624-solved-substring/#findComment-296270 Share on other sites More sharing options...
Asday Posted July 12, 2007 Author Share Posted July 12, 2007 What you're looking for is substr <?php $s = 'http://www.php.net'; if (substr($s, strlen('http://'))) { //code ... it starts with http:// ... so what to do? }else { //code ... it doesn't start with http:// ... so what to do? } ?> Thanks! That worked (Had to fiddle with it to get it to work with my existing code) <?php if (($_FILES["file"]["type"] == "image/gif") // ... && ($_FILES["file"]["name"] !== (substr($_FILES["file"]["name"], strlen("http://"))))) { // upload } else { echo "Sod off."; } ?> Link to comment https://forums.phpfreaks.com/topic/59624-solved-substring/#findComment-296277 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.