Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 03-08-2005, 10:02 AM   #1
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
php image upload problem

i'm building a tgp script, i have a problem with the thumbnails, they come out distorted.

here is the code:
PHP Code:
if(!eregi("(.jpeg|.jpg)"$_FILES['imagefile']['name']))
{
    echo 
"please upload only files in jpg format";
    die;
}
if(
$_FILES['imagefile']['type'] != "image/jpeg" && $_FILES['imagefile']['type'] != "image/pjpeg")
{
    echo 
"please upload only files in jpg format";
    die;
}

$upload_path='/virtual/danny/images/myimage.jpg';
copy ($_FILES['imagefile']['tmp_name'], $upload_path) or die ("An Error has occured: the thumbnail could not be uploaded to the server"); 
i'm missing something here. what is it?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 10:04 AM   #2
Barefootsies
Choice is an Illusion
 
Barefootsies's Avatar
 
Industry Role:
Join Date: Feb 2005
Location: Land of Obama
Posts: 42,635
Could be something in the PHP library??

__________________
Should You Email Your Members?

Link1 | Link2 | Link3

Enough Said.

"Would you rather live like a king for a year or like a prince forever?"
Barefootsies is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 10:37 AM   #3
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by Barefootsies
Could be something in the PHP library??


what could it be in the PHP library?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 01:43 PM   #4
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
any ideas?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 01:43 PM   #5
mistress69
Confirmed User
 
Join Date: Feb 2005
Posts: 2,804
bump for ya
mistress69 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 01:45 PM   #6
StuartD
Sofa King Band
 
StuartD's Avatar
 
Join Date: Jul 2002
Location: Outside the box
Posts: 29,903
is the directory you're copying to chmod to 777?
Does the form have the proper encode type?
StuartD is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 01:47 PM   #7
BastarD
Confirmed User
 
Join Date: Apr 2004
Location: Very close to that Jack Daniels bottle..
Posts: 6,341
You should check out PHP freaks forums, I'm sure guys there will help ya
BastarD is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 02:01 PM   #8
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Suggestion: Copy the file with a .phps extension and put it someone where people can click a link to see it. GFY's 'hahahaha' filter makes it really difficult to understand what you're trying to do.

FWIW - Filtering based on filename isn't as reliable as GetImageSize() to determine if a file is really a jpg or not.

Last edited by rickholio; 03-08-2005 at 02:04 PM..
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 02:04 PM   #9
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by NichePay - StuartD
is the directory you're copying to chmod to 777?
yes

Quote:
Originally Posted by NichePay - StuartD
Does the form have the proper encode type?
do you mean this: enctype="multipart/form-data" in the form tag?
__________________
* Mainstream ? $65 per sale
* new male contraception

Last edited by Zester; 03-08-2005 at 02:05 PM..
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 02:17 PM   #10
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by rickholio
Suggestion: Copy the file with a .phps extension and put it someone where people can click a link to see it. GFY's 'hahahaha' filter makes it really difficult to understand what you're trying to do.

FWIW - Filtering based on filename isn't as reliable as GetImageSize() to determine if a file is really a jpg or not.
http://www.geocities.com/dianna_zelda/upload.html
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 02:49 PM   #11
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Quote:
Originally Posted by Zester
That snippit of code should work fine, aside from what I said about getimagesize(), and presuming that permissions are set up correctly. In what way are the thumbnails distorted? And are you creating the thumbnails via PHP from full size images, or are you uploading them?
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 03:31 PM   #12
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by rickholio
That snippit of code should work fine, aside from what I said about getimagesize(), and presuming that permissions are set up correctly. In what way are the thumbnails distorted? And are you creating the thumbnails via PHP from full size images, or are you uploading them?
they come up distorted as a blur of colors - completely corrupted.
I'm just using the above script, not resizing or anything.
just uploading.
after upload, I try to look at the image via browser as:
http://mydomain.com/myimage.jpg and there it is. distorted.

I already emailed my host (revsharehosting.com) about this, but if I could only tell him what he can do to fix this, because if doesn't - I don't and i'm fucked.
__________________
* Mainstream ? $65 per sale
* new male contraception

Last edited by Zester; 03-08-2005 at 03:33 PM..
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 03:35 PM   #13
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
here is the form by the way:
[HTML]
<form name="form1" method=hahahahahaha action="" enctype="multipart/form-data">
<input type="file" name="imagefile">
<input type="submit" name="Submit" value="Submit">
</form>
[/HTML]
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-08-2005, 04:33 PM   #14
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Can you post links to the before and after? There definately sounds like some kind of corruption is going on, I'm curious to see what's happening to the image itself.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 09:04 AM   #15
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
the response from the host is that GD is needed for this
what do you guys think about that?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 10:06 AM   #16
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
i think this is something to do with the type of the file (Binary / Ascii)
how do I set those on upload or move ?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 10:48 AM   #17
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
GD isn't required for file uploads, only for times when you want to do things like GetImageSize(). If you're purely shuffling bytes around, you don't need it.

Binary/Ascii only should apply when dealing with FTP transfers. Web-based uploads don't have the same caveats (or at least they shouldn't!), but that's part of the reason why I wanted to see a before image and an after image, so I could see if there was some sort of corruption going on during the upload phase.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 11:27 AM   #18
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by rickholio
GD isn't required for file uploads, only for times when you want to do things like GetImageSize(). If you're purely shuffling bytes around, you don't need it.

Binary/Ascii only should apply when dealing with FTP transfers. Web-based uploads don't have the same caveats (or at least they shouldn't!), but that's part of the reason why I wanted to see a before image and an after image, so I could see if there was some sort of corruption going on during the upload phase.
i DO use getimagesize() but that's seems to get the vars ok - please look at the code i posted, i posted a link

here is a "before": (used upload via php)
http://footfetishgallery.net/gallery/thumbnails/04.jpg

here is an "after": (used FTP)
http://footfetishgallery.net/gallery/thumbnails/04b.jpg
__________________
* Mainstream ? $65 per sale
* new male contraception

Last edited by Zester; 03-09-2005 at 11:30 AM..
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 12:22 PM   #19
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
just added "sleep(20);" before the "copy" command thinking the image might be copied before it has been fully uploaded or something - I got the same result.

maybe i did'nt put it in the right place
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 12:38 PM   #20
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Quote:
Originally Posted by Zester
i DO use getimagesize() but that's seems to get the vars ok - please look at the code i posted, i posted a link

here is a "before": (used upload via php)
http://footfetishgallery.net/gallery/thumbnails/04.jpg

here is an "after": (used FTP)
http://footfetishgallery.net/gallery/thumbnails/04b.jpg
Can't grab em... looks like you have some variety of hotlink protection on. Can you make a page that links to those images?

AFAIK, the php page doesn't even run until the entire request has completed, and file uploads are part of the request... so no sleep() would be necessary.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 01:04 PM   #21
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by rickholio
Can't grab em... looks like you have some variety of hotlink protection on. Can you make a page that links to those images?

AFAIK, the php page doesn't even run until the entire request has completed, and file uploads are part of the request... so no sleep() would be necessary.
try this:
http://footfetishgallery.net/gallery/temp.html




i'm really out of ideas about this
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 03:59 PM   #22
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Aha, I think I have it.

I did a 'strings' on your 04b.gif file and found the following:

-----------------------------7d51181aaf4
Content-Disposition: form-data; name="imagefile"; filename="C:\backup\guitarstuff\project\tgp\xf\1\0 4.jpg"
Content-Type: image/pjpeg

It would appear that you're saving the entire raw response string, and not purely the image itself. It maybe the way the file gets handled in the code?

Here's what I've used in the past:

Code:
      if(is_uploaded_file($_FILES[img][tmp_name])) {
         $szarr = getimagesize($_FILES[img][tmp_name]);
         if($szarr[2]=IMAGETYPE_JPEG) move_uploaded_file($_FILES[img][tmp_name], $file_target);
      }
The only other alternative is that your webserver is not correctly separating out the different form submission elements, in which case you have bigger problems.

HTH.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 04:10 PM   #23
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Hi,

This might be of help to you, but I am not sure. It's something I use to upload and move a file to a directory on my server and the GD library also makes a thumbnail version of the image and uploads it to the same directory, but adds a prefix the image name.

I put it in a .txt for you:

http://www.penis-enlargement-product.us/misc/zester.txt
__________________
subarus.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-09-2005, 04:27 PM   #24
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Quote:
Originally Posted by calmlikeabomb
Hi,

This might be of help to you, but I am not sure. It's something I use to upload and move a file to a directory on my server and the GD library also makes a thumbnail version of the image and uploads it to the same directory, but adds a prefix the image name.

I put it in a .txt for you:

http://www.penis-enlargement-product.us/misc/zester.txt
This is very similar to what I do, although I use PNG for very small thumbnails instead of jpeg (I find they retain detail better at the small sizes). I'm not entirely convinced that his server or browser are working as advertised though. The uploaded image is, for some reason, substantially larger than the source... additionally, it appears as though there's about 2k of data at the head of the image, followed by the request header and another copy of the full image. Something Is Just Not Right(tm), and I've got a suspicion that it's something amiss in the actual upload process, not the post-upload processing.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2005, 10:14 AM   #25
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by rickholio
Aha, I think I have it.

I did a 'strings' on your 04b.gif file and found the following:

-----------------------------7d51181aaf4
Content-Disposition: form-data; name="imagefile"; filename="C:\backup\guitarstuff\project\tgp\xf\1\0 4.jpg"
Content-Type: image/pjpeg

It would appear that you're saving the entire raw response string, and not purely the image itself. It maybe the way the file gets handled in the code?

Here's what I've used in the past:

Code:
      if(is_uploaded_file($_FILES[img][tmp_name])) {
         $szarr = getimagesize($_FILES[img][tmp_name]);
         if($szarr[2]=IMAGETYPE_JPEG) move_uploaded_file($_FILES[img][tmp_name], $file_target);
      }
The only other alternative is that your webserver is not correctly separating out the different form submission elements, in which case you have bigger problems.

HTH.

tried the code you posted here and got the same result mate
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2005, 11:29 AM   #26
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
It's a strange bug... the php code is correct, the form element looks right, and the picture is presumably getting to the right place, the problem is that it's getting messed in the upload.

Have you tried uploading it using a different browser? If it works via a new browser, then it's your old one that's breaking... if it's still buggered, then somehow your server is broken. Having that multipart header embedded in the upload stream is very odd indeed. I'm leaning towards a broken server at this point.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2005, 12:12 PM   #27
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by rickholio
It's a strange bug... the php code is correct, the form element looks right, and the picture is presumably getting to the right place, the problem is that it's getting messed in the upload.

Have you tried uploading it using a different browser? If it works via a new browser, then it's your old one that's breaking... if it's still buggered, then somehow your server is broken. Having that multipart header embedded in the upload stream is very odd indeed. I'm leaning towards a broken server at this point.

tried it with other browsers
same thing

any idea how the hell my host can handle this? what to tell him?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2005, 12:19 PM   #28
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
Is your host using recent version of php and apache?
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2005, 02:06 PM   #29
Zester
Confirmed User
 
Zester's Avatar
 
Industry Role:
Join Date: Jul 2003
Posts: 5,344
Quote:
Originally Posted by woj
Is your host using recent version of php and apache?
do you think it can be something to do with the PHP or Apache version?
__________________
* Mainstream ? $65 per sale
* new male contraception
Zester is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 03-10-2005, 04:44 PM   #30
rickholio
Confirmed User
 
Industry Role:
Join Date: Jan 2004
Location: Nor'easterland
Posts: 1,914
Quote:
Originally Posted by Zester
tried it with other browsers
same thing

any idea how the hell my host can handle this? what to tell him?
Lay it out like this:

- Your images are being corrupted on upload.

- You've checked, changed, and confirmed that the code used to process uploads is correct and verified by third parties

- The image itself is being corrupted in the upload process. The uploaded image contains part of the headers from the submission, plus extra crap that doesn't belong. Show them the before and after, and point out that the uploaded image ends up LARGER than the original image.

- Make sure they know you've tried uploading with different browser types, removing a broken browser as being the reason for the failure

- Try uploading other images to see if it happens regardless of the source, which will remove the possibility of a broken graphic as the cause

- By the process of elimination (not browser, not code, not image) the only other option would be the way the server handles it.
rickholio is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.