Jump to content

Directory help with php


pankirk

Recommended Posts

Hi.

 

So I have a php script that shrinks an image making it a thumbnail image and then it uploads it to the server in a directory called "downloads"

 

The problem I'm having is that I have the code in a folder named "includes" and I need everything to be copied to the "downloads" directory. "downloads" and "includes" are on the same level, but like i said before, my code is inside the "includes" folder.

 

So heres my code that I have:

 

$dest_image = "../downloads/$itemType/$itemId/".$now_time.$_FILES['preview_image']['name'];
copy($_FILES['preview_image']['tmp_name'], $dest_image);

 

(obviously theres other code around it, this is just whats causing the problem)

 

Heres the result when I run the script:

 

Warning: copy(../downloads/themes/25/20091221174122Jellyfish.jpg) [function.copy]: failed to open stream: No such file or directory

 

I obviously am having trouble with the "../" and "/" before the directory name. So what am I doing wrong? Thanks!

 

-P

Link to comment
https://forums.phpfreaks.com/topic/185962-directory-help-with-php/
Share on other sites

I'd suggest echo'ing out the value of $dest_image. The chances are it does not have the value you expect. I'm assuming the code in the 'include' folder is actually includeed in another file, now I always get this the wrong way around but I believe that may make the path used relative to the file that includes it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.