General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 9th, 2003, 03:29 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
pics not copying

i have a script which moves pictures from on directory to another, but it isn't copying them correctly. here is the code:

PHP Code:
if(mysql_query($adduser))
    {    
mkdir($_SERVER['DOCUMENT_ROOT'] . '/pics/profiles/' $_POST['userid'], 0755);
        
mkdir($_SERVER['DOCUMENT_ROOT'] . '/pics/profiles/' $_POST['userid'] . '/thumbs/'0755);
    
        
copy($_SERVER['DOCUMENT_ROOT'] . '/pics/pending/' $_POST['userid'] . '/' $strPicName ''
        
$_SERVER['DOCUMENT_ROOT'] . '/pics/profiles/' $_POST['userid'] . '/' $strPicName '');
        
        
copy ($_SERVER['DOCUMENT_ROOT'] . '/pics/pending/' $_POST['userid'] . '/thumbs/' $strPicName ''
        
$_SERVER['DOCUMENT_ROOT'] . '/pics/profiles/' $_POST['userid'] . '/thumbs/' $strPicName '');
                 
        
unlink($_SERVER['DOCUMENT_ROOT'] . '/pics/pending/' $_POST['userid'] . '/' $strPicName '');
        
unlink($_SERVER['DOCUMENT_ROOT'] . '/pics/pending/' $_POST['userid'] . '/thumbs/' $strPicName ''); 


here is the error message I'm getting:

Warning: copy(/home/thecheat/passedtime.com/pics/pending/68/chico_megan1.jpg>): failed to open stream: No such file or directory in /home/.padrino/thecheat/passedtime.com/security/registration.pcgi on line 165

Warning: unlink(/home/thecheat/passedtime.com/pics/pending/68/chico_megan1.jpg>): No such file or directory in /home/.padrino/thecheat/passedtime.com/security/registration.pcgi on line 170

so it isn't copying right, and I was wondering, why are there little brackets on the end of it? ie: chico_megan1.jpg>): is that normal? the picture does exist and I can't figure it out!
thanks
__________________
hey it's the CHARKING

Reply With Quote
  #2  
Old December 9th, 2003, 06:14 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
I have a feeling you will need the permissions to be '0777' Try it and see what happens.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old December 9th, 2003, 06:25 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Also, in the future, a quick way to check if file permissions are a problem when working with files on the filesystem, you can use:
PHP Code:
 $file "./testfile.txt";

clearstatcache();
if (
file_exists($file)) {
  print 
realpath($file).' exists';   
} else {
  die(
realpath($file).' does not exist!');
}

clearstatcache();
if (
is_readable($file)) {
  print 
' and is readable!';
} else {
  print 
' but is not readable!';


Reply With Quote
  #4  
Old December 9th, 2003, 07:02 PM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
well i jsut tried that changing the permissions, and that didn't work. I had changed them to 755 because I had thopught that my host had required that. I got the same error message (although the user, me, was able to add the pictures to the site from my computer... !! i can't udnerstand this. I will ask the host again, I have asked before and they said they didn't know what te problem was, that it was a programming error, and not something they could fix... um ok. thank you.

Reply With Quote
  #5  
Old December 10th, 2003, 12:56 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
So you are absolutely certain that you have permission to access the file you are copying from?

What about the directory you are copying to? What are the exact permissions on those files?

Who is the owner of the files?

Is your host running apache?

Reply With Quote
  #6  
Old December 10th, 2003, 02:41 AM
thecharking thecharking is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 187 thecharking User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via AIM to thecharking
I own the files, I thought. I mean I put them there and it's my website... I've never had a host before so it's all pretty new to me. I decided that maybe the folders I had made weren't set with the right permissions, so I made a quick script and executed it to set the files to 755 (the host says this is what I have to do, because they use something else to make it work right, so don't use 777). And yes it is running apache. I'm going to also post a message to the hosts' forum.

Reply With Quote
  #7  
Old December 10th, 2003, 03:06 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
It does not matter what your account username is at your host.
If your account name is "thecheat", and you uploaded the files or created them under the shell, they will be owned by "thecheat"
(Example: chown thecheat chico_megan1.jpg)

Web servers do not run under the user account (or they should not)... it would be a security risk. The web server normally runs its process under a special, no privileged user called "nobody" or "web" or "www" or "apache", with the former being the most popular. (In IIS the equivalent user is IUSR_%COMPUTERNAME%)

Try chowning some of the files to the "nobody" user and see if you can access them. I have a good feeling that is the issue (permissions).

Reply With Quote
  #8  
Old December 11th, 2003, 05:26 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
yes also you cant set persmission on files that are on a windows platform, only works for linux...if you are running a windows platform, you will have to upload to the cgi-bin folder

Reply With Quote
  #9  
Old December 11th, 2003, 05:48 PM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Quote:
yes also you cant set persmission on files that are on a windows platform, only works for linux...if you are running a windows platform, you will have to upload to the cgi-bin folder
That is actually not the case. On the windows platform you have a user that is running the IIS process. The user is IUSR_%COMPUTERNAME% (example: IUSR_server1).

Permissions can be set on directories regarding this user and that would determine whether your could
a. write to (upload) a particular directory
b. browse the directory
...

As for uploading to the cgi-bin folder... I doubt that would be good for security. Would you really want to allow file uploads to your cgi-bin directory so a potential hacker could upload some virus, then activate the virus running the app from the web browser?

Reply With Quote
  #10  
Old December 11th, 2003, 07:57 PM
Bruski Bruski is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Toronto, Canada
Posts: 192 Bruski User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
note to self *find out how laidback has all the answers* =]

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > pics not copying


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT