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 Quote Link to comment 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? } ?> Quote Link to comment 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."; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.