Jump to content

.htaccess no image


Solar

Recommended Posts

:D

 

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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.