/    Sign up×
Community /Pin to ProfileBookmark

PHP glitch found?

I wrote php code to upload jpg image to server which then creates thumbnails of those uploaded images. Everything works perfect. And then I figured out that the thumbnails cannot be altered e.g. renamed, deleted, copied, while the original uploaded images can.

Anybody seen that weird stuff already? ? what could be wrong? Thanx!

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@chazzyJan 02.2006 — sounds like a bug in your script, not in php.

don't forget, if you're using a webhost w/ shared environment, the images will be owned by the php user. you can change it so that they chown to another user.
Copy linkTweet thisAlerts:
@SpectreReturnsJan 02.2006 — PHP doesn't have bugs like that. PHP has bugs like certain functions not acting propperly or wrong math or something. This is mearly a problem of bad logic (after uploading, always [b]chmod("file.ext", 0755);[/b]).
Copy linkTweet thisAlerts:
@FafmaschineauthorJan 02.2006 — Check out the image:[URL=http://www.moj-album.com/slike/4849/HXdW4lJn_HhDRGX6.jpg]image[/URL]

Still doesn't work! As you can see all the files are in the folder created by me and that folder has permission set to 777.

uploadimage.php uploads [B]milko.jpg[/B] from my home PC to that folder on remote server.

I can do whatever I want with [B]milko.jpg[/B], but with [B]thumb_milko.jpg[/B] I always get Warning: rename(thumbnail_milko.jpg,file2.jpg): No such file or directory in uploads/uploadimage.php on line 43

[B]Neither I can chmod thumb_milko.jpg from 644 to 777...[/B]

The fact that I chmod uploaded [B]milko.jpg[/B] or not doesn't change anything either. ?
Copy linkTweet thisAlerts:
@bokehJan 02.2006 — Why doesn't your script create it with the correct filename in the first place?
Copy linkTweet thisAlerts:
@chazzyJan 02.2006 — Check out the image:[URL=http://www.moj-album.com/slike/4849/HXdW4lJn_HhDRGX6.jpg]image[/URL]

Still doesn't work! As you can see all the files are in the folder created by me and that folder has permission set to 777.

uploadimage.php uploads [B]milko.jpg[/B] from my home PC to that folder on remote server.

I can do whatever I want with [B]milko.jpg[/B], but with [B]thumb_milko.jpg[/B] I always get Warning: rename(thumbnail_milko.jpg,file2.jpg): No such file or directory in uploads/uploadimage.php on line 43

[B]Neither I can chmod thumb_milko.jpg from 644 to 777...[/B]

The fact that I chmod uploaded [B]milko.jpg[/B] or not doesn't change anything either. ?[/QUOTE]

It's owned by apache. That's why you can't change it. When you call rename, the parameters should have quotes around them, try it again like that.
Copy linkTweet thisAlerts:
@FafmaschineauthorJan 02.2006 — I call it like that:
[code=php]rename('thumbnail_milko.jpg', 'file2.jpg');[/code] and I get warning

or
[code=php]rename("thumbnail_milko.jpg", "file2.jpg");[/code] I also get the warning.

With originally uploaded file milko.jpg both upper codes work just fine...
Copy linkTweet thisAlerts:
@chazzyJan 02.2006 — Hmmm..

are you able to chmod it from the script? Or did you try that already? what about the chgroup command?
Copy linkTweet thisAlerts:
@FafmaschineauthorJan 03.2006 — No ch-thing works...
Copy linkTweet thisAlerts:
@chazzyJan 03.2006 — the only thing I can think of right now is that your webhost has some kind of advanced configuration, where the PHP user isn't in the apache group, but when it creates things it chgroup's to apache.

I'm a little stumped.
Copy linkTweet thisAlerts:
@FafmaschineauthorJan 03.2006 — Thanx chazzy for your time and help! Got nothing else to do than call my webhost personally, what he has going on on that damn server :mad: !

I'll post up the outcome for you ?
Copy linkTweet thisAlerts:
@FafmaschineauthorJan 03.2006 — It's funny as hell!!

I called my webhost and he said the problem with folders is that they have PHP safe mode on. And as for me he said that maybe I have errors in my PHP code.

But then miraculously after a few hours my "since-then-wrong" PHP code started to work!! ?

Now you can see what small phone call can achieve!!
Copy linkTweet thisAlerts:
@chazzyJan 03.2006 — score one for obscure php settings being on.

good luck.

i had a similar experience, having to do with mail, my host required everyone to provide from tags in the headers but didn't tell anyone. i asked them simply where it was stated in their TOS, no response yet.
×

Success!

Help @Fafmaschine spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...