Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts

    imagejpeg function only working 50% of the time

    Could anyone explain to me how it's possible that the function works half the time, but fails to do so the other half. This is the warning I get:

    Warning: imagejpeg() [function.imagejpeg]: Unable to open 'Afbeeldingen/wie-is-wie/9.jpg' for writing: Invalid argument in C:\Users\Ron\Dropbox\KBS\Website\scripts\functies.php on line 508

    As you can see I'm running it on a shared dropbox account, I'm not sure whether or not that has anything to do with the issue.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    If it works 50% of the time you'll need to verify the conditions in which it does write (does it only write clean? Does it just fail on overwrite?). The error doesn't appear to be that of a security issue, so you'll need to verify that the path is valid.
    Since you post no code to go with this, we can't help much PHP wise.

  • #3
    New Coder
    Join Date
    Oct 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts
    The thing is, it works 50% on every file you can imagine. Sometimes image A works, the next time it doesn't and so on. The same goes new images and overwrites. It's got me confused...

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    If it fails on image A, and then you perform the same does it then work? If it consistently fails with a particular file, then there is likely something particular causing it. If its random, that is likely not a direct PHP error (although we have no way to verify that).

  • #5
    New Coder
    Join Date
    Oct 2011
    Posts
    24
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Yes that's the problem, it's random...

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    Quote Originally Posted by Krtoffel View Post
    Yes that's the problem, it's random...
    Without seeing code, it is impossible to verify.
    To me, it appears that its either a path issue (ie: this is technically invalid: 'Afbeeldingen/wie-is-wie/9.jpg', but would likely work relative), but if its inconsistent, fails on a specific image and then is successful on that same image, this all points to a host issue.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •