MyBB Community Forums

Full Version: damn forward slash is killing me
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
so here i am to rant again

$location = $mybb->settings['pics_dir']; // "pics"

if(!@move_uploaded_file($input['tmp_name'], MYBB_ROOT.$location."/".$filename))

results in this damn backslash in the wrong place and the files moves to mybb root for some reason instead of going to the pics dir

C:\xampp\htdocs\mybb/pics 
AngryAngry

so im pissed hope i can get this sorted soon
Shouldn't you be using localhost in the address bar?

Or am I missing the problem, I am a little confused.
nah i was uploading the file and it kept going in the myBB root folder

so i just echo'd

MYBB_ROOT.$location."/".$filename

and instead of
C:\xampp\htdocs\mybb\pics
or even
C:/xampp/htdocs/mybb/pics
i get
C:\xampp\htdocs\mybb/pics
note the forward--forward--back--slash
But if you use http://localhost/mybb/pics/ it'll work, (I think) that's what Ryan was getting at. The C: path will always use \ but if you use it the 'normal' way with http://localhost/ it'll be OK with a /
Yeah, Matt said what I was getting at. Smile
i think i might be confusing everyone

php script to upload file is at

htpp://localhost/upload.php

when i feed it using the $_FILES['picture']

it should upload it to mybb_root/pics/pic001.gif
but instead it uploads to mybb_root/pic001.gif

to debug my script i went back to check the variables and thought to check if it was actually pointing to the right spot to upload the file

so a small edit so that my file upload script upload.php (for testing purposes) now read

echo MYBB_ROOT.$location;

where $location is $mybb->settings['pic_dir']
and then i access

http://localhost/upload.php and the output is

C:\xampp\htdocs\mybb/pics
If it's one thing I hate, it's this.

What happens if you do:

MYBB_ROOT.$location."\\".$filename
The strange thing is, Windows has been able to handle '/' in paths for a while now. Which version of Windows are you using?
im using windows 7

and @Tomm M -- tried that Big Grin ---- nada

plus what happens when someone runs it on a linux based host
DIRECTORY_SEPARATOR
You can use that constant.