Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lost image

Status
Not open for further replies.

dragons2266

Technical User
May 22, 2007
5
GB
Hi. I recently changed hosts and now my script (for resumes) only partly works. It will upload the typed info but not the images.

Am quietly going insane. Can anyone help?

Have tried every CHMOD under the sun and have fiddled with path ways but to no avail. I am sure it’s simple because it worked on the last server with no problems and I didn't change anything when we moved apart from pathways.

Can anyone take pity on me? Thanks so much


I think the problem might lie in the bit below somewhere but I am guessing:

___________________________

#upload picture
if ($image ne ""){
$image =~ m/^.*(\\|\/)(.*)/;
$temp = $2;
$temp =~ tr/[A-Z]/[a-z]/;
$temp =~ s/%20//gi;

open(LOCAL,">/var/
while (<$image>) {
print LOCAL $_;
}

$photo = "<center><img border=0 src=\"$imageUrl/cv/$username/$temp\"></center>";
$pictureurl = "$imageUrl/cv/$username/$temp";
}
else{
if ($pictureurl ne ""){
$photo = "<center><img border=0 src=\"$pictureurl\"></center>";
}
else{
$photo = "No Picture is Available";
}
}
 
A binmode after the open?
You didn't give much details on what you see (or don't see).
You should add some print statements for debugging purposes and watch what happens.
 
Thanks for replying

Unfortunately the guy who designed the script is no longer available so I can't ask him for help. I know only a little about cgi, am flying by the seat of my pants!

The script creates files and directories, it just doesn't upload the image, the rest of the resume is fine. If that wasn't loading either, I'd have a better idea where to start but given their cv loads but the images don't I'm lost.

I am not sure what you mean by binmode after the open

You can check out what the script should do:

And what it doesn't (see missing image box)


Thanks again for your time.

Jen
 
Just add a line
Code:
binmode LOCAL;
after the open.
If your new host is Windows based and the former was Linux based, this should solve the problem.
 
Hi Prex1

So it should read:

#upload picture
if ($image ne ""){
$image =~ m/^.*(\\|\/)(.*)/;
$temp = $2;
$temp =~ tr/[A-Z]/[a-z]/;
$temp =~ s/%20//gi;

open(binmode LOCAL;">/var/

while (<$image>) {
print LOCAL $_;
}

$photo = "<center><img border=0 src=\"$imageUrl/cv/$username/$temp\"></center>";
$pictureurl = "$imageUrl/cv/$username/$temp";
}
________________________________________________

Sorry to be so thick. It's probably obvious but I just don't want to stitch everything up!

Thanks

Jen
 
Sorry, tried it.

Still no pic but uploaded thank you message to you ;-)

Any other ideas?


#upload picture
if ($image ne ""){
$image =~ m/^.*(\\|\/)(.*)/;
$temp = $2;
$temp =~ tr/[A-Z]/[a-z]/;
$temp =~ s/%20//gi;

open(LOCAL,">/var/ binmode LOCAL;

while (<$image>) {
print LOCAL $_;
}
 
I just checked the urls, and the one with the 'missing image' has actually tried to upload an English translation of their CV as a word document, instead of an image.
 
In your last posted link there is no file name in the HTML, only the path as src=" whilst in the two preceding ones there was a filename.doc
So it seems that the variable $temp sometimes doesn't take a correct value.
Also the construct
while(<$image>){}
is odd to me, as current versions of Perl should take <$image> as a typeglob (just like <*.*>) and return the content of $image at the first call and undef subsequently. If on the former host you had an old version of Perl, this could be another reason for the behavioral change (not sure though).
It is anyway safer to write:
Code:
local(*F);
open(F,$image);
while(<F>){
  print LOCAL $_;
}
close F;
Also this should work:
Code:
local(*F);
open(F,$image);
print LOCAL <F>;
close F;


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top