Solar Posted May 20, 2010 Share Posted May 20, 2010 Question #1 RewriteBase /photo/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} \.(gif|jpg|jpeg|png)$ RewriteRule .* /photo/unknown.png [L] Is it possible to remove those extensions and have just nothing? Like say if my photo was; website.com/photo/Solar If Question #1 fails; Question #2 $username = $_SESSION['username']; $target = "./photo/"; $path = pathinfo($_FILES['uploaded']['name']); //gather file data $targetnew = $target.$_SESSION['username'].$path['.']['extension']; $target = $targetnew;unset($targetnew); $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; There is something wrong in this coding that will not allow uploaded images have an "extension", What can I do to fix this? Quote Link to comment Share on other sites More sharing options...
smarble53 Posted May 20, 2010 Share Posted May 20, 2010 QUESTION 1) try this. it works when i have it set to .php: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.png [L,QSA] RewriteRule ^(.*)$ $1.jpg [L,QSA] RewriteRule ^(.*)$ $1.jpg [L,QSA] and so on... QUESTION 2) this is what i do: $username = $_SESSION['username']; $target = "./photo/"; $filename = $_FILES['uploaded']['name']); //gets the file name - file.jpg $targetnew = $target.$username."/".$filename; // $target = $targetnew;unset($targetnew); $ok=1; if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploaded']['name']). " has been uploaded"; i'm sure there are other more reliable and smiled-upon ways to do this, but this is how i get the name and extension seperately: $filename = $_FILES['uploaded']['name']; $filenamearray = explode(".", $filename); $name = $filenamearray[0]; //the part before the first period $ext = $filenamearray[1]; //after the period so in theory, $_FILES['uploaded']['name'] should be the same as $name.".".$ext . before i upload the files, i make sure there is only one period in the filename. 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.