Re: [PHP] Question regarding fopen



Hi, I'm having a strange problem with fopen

For clearence, here is the phpinfo page:
http://www.grondengoed.nl/phpinfo.php

I will shortly explain the problem I'm having:
$imagenamesmall = $foldersystem . '/' . $id . $imgstr . '-s' .
$i . '.jpg';
echo $imagenamesmall; // For debugging purposses --> returns
exactly what I want.

//attempt to create folder
@mkdir($foldersystem);
@chmod($foldersystem, 0777);


//save picture
if(!($handle = fopen($imagenamesmall, 'w'))){
echo "Cannot open file (31)";
exit;
}

//$imagesmall, contains the image resource

if(fwrite($handle, $imagesmall) === FALSE) {
echo "Cannot write to file (32)";
exit;
}

fclose($handle);

Erverything works perfectly fine.But one thing, it doesn't give the
file the name that it should get. A name for instance has to be:
54961tdtdtdtd-s0.jpg
The number is the id of the database row, the 8 characters are random.
-s stands for small and 0 is the picture index.
When I echo the value, I get what I want. But when I save it, the
random 8 character string had become a totally different 8 character
string :S.

I have googled and checked things over and over again, cost me hours
and I still haven't found the reason. What is noticeable is that when
I leave one character away from the name, the value IS what it schould
be:S.

I really hope you can help me, if you need further info yust ask.

Thanks in advance.

regards,

Joep Roebroek

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



What version of PHP?

My guess is that the mkdir is failing and the file is going to some weird
place.
You can do the chmod as part of the mkdir: bool mkdir ( string $pathname
[, int $mode [, bool $recursive [, resource $context ]]] )

Print/test the result of your mkdir.

If is doing what you think then it sounds like a memory overwriting bug.


.



Relevant Pages

  • Re: Scrolling text in a stationary label help needed
    ... Using the TextWidth function to get your values you can simply divide the TextWidth of the entire string by the TextWidth of a single space character. ... At the moment the first time the string is printed into the Picture box it is printed at x coordinate zero. ... When the time comes to move the string to the left by one pixel the following happens. ...
    (microsoft.public.vb.general.discussion)
  • Re: Is the length of a picture string always equal to the length of the string DISPLAYed?
    ... the length of the output does not match the length of the string? ... in the PICTURE clause occupy the same space is dependent on whether they're ... So I would suggest that presuming it is Universally and Eternally True that ... the PICTURE character string is the same length as the USAGE DISPLAY datum ...
    (comp.lang.cobol)
  • Re: Left() Need the equivalent of this
    ... Whats wrong with this picture? ... You are only returning 1 character. ... Look at HELP for the MID function, or check out the prompts as you enter the ... length of the rest of the string. ...
    (microsoft.public.excel.programming)
  • Re: TR - Day 2 of 8
    ... I have fairly straight blonde hair. ... into a Character Dining Restaurant. ... they take your picture against a wall with some African ... trail of those little Mickey Waffles for them to follow back to our table.. ...
    (rec.arts.disney.parks)
  • Re: Standards question on edited fields
    ... as a "simple insertion character". ... impossible for the compiler to distinguish a syntactically-correct PICTURE ... Unisys now actively discourages the use of this convention. ... character except the blank could be used as a simple insertion character by ...
    (comp.lang.cobol)