Jump to content


Photo

File Upload Query?


  • Please log in to reply
2 replies to this topic

#1 Solarpitch

Solarpitch
  • Members
  • PipPipPip
  • Advanced Member
  • 708 posts
  • LocationDublin, Ireland

Posted 18 October 2006 - 07:46 PM

Hi,

I have the following code. It uploads a submitted image to the path C:\Webapps\test\Images. When its stores the Image the name of the Image becomes "ImageMe1.jpg" where Me1 is the name of the photo. I think its somthing to do with my path?

And just on the side . . what would be a cool way to store the path into the database? (Answer this if you get time, otherwise my first query will do)  :}


$uploaddir = "./Images./Images";
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
   echo "File is valid, and was successfully uploaded.\n";
} else {
   echo "Possible file upload attack!\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";


Welcome to 9AM Monday, the furthest point away from 5PM Friday.

#2 sanfly

sanfly
  • Members
  • PipPipPip
  • Advanced Member
  • 344 posts
  • LocationNew Zealand

Posted 18 October 2006 - 11:04 PM

What's the path of the images directory in relation to the directory where your script is being run? 

I'm a little confused by this:

$uploaddir = "./Images./Images";


Also, is there any reason why you are using basename()?  I dont think its necessary
If you're not part of the solution, you're part of the precipitate

#3 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 19 October 2006 - 09:15 AM

i am on the same line as sanfly. what is with this:
$uploaddir = "./Images./Images";
that dosnt really make any sense....
Good luck with your coding.
Jason / ProjectFear / Jaysonic




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users