Page 2 of 3
Posted: Mon Apr 19, 2004 7:46 pm
by Chris Corbyn
lol

Posted: Mon Apr 19, 2004 7:55 pm
by hward
i gained an extension but no jpg
Posted: Mon Apr 19, 2004 7:56 pm
by hward
i mean a period but no jpg behind it
Posted: Mon Apr 19, 2004 7:57 pm
by Chris Corbyn
Can you show the full code again?
Posted: Mon Apr 19, 2004 7:58 pm
by hward
<?
if ($img1_name != "") {
$parts = pathinfo($img1);
@copy("$img1", "pictures/$new_name.$parts[extension]")
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
?>
<HTML>
<HEAD>
<TITLE>Successful File Upload</TITLE>
</HEAD>
<BODY>
<H1>Success!</H1>
<P>You sent: <? echo "$img1_name"; ?>, a <? echo "$img1_size"; ?>
byte file with a mime type of <? echo "$img1_type"; ?>.</P>
</BODY>
</HTML>
Posted: Mon Apr 19, 2004 8:00 pm
by Chris Corbyn
Try this
Code: Select all
<?
if ($img1_name != "") {
$parts = pathinfo($img1);
@copy("$img1", "pictures/'.$new_name.$parts[extension].'")
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
?>
I've just added the '. bits to cover the variables
Posted: Mon Apr 19, 2004 8:02 pm
by hward
got the file name as '.12..'
Posted: Mon Apr 19, 2004 8:03 pm
by hward
should have came out 12.jpg
Posted: Mon Apr 19, 2004 8:07 pm
by Chris Corbyn
Just do this instead. Don't bother with pathinfo()
Code: Select all
<?php
if ($img1_name != "") {
$parts = explode('.', $Img1);
array_reverse($parts);
@copy("$img1", "pictures/'.$new_name.$parts[0].'")
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
?>
Posted: Mon Apr 19, 2004 8:10 pm
by hward
i got it to work
<?
if ($img1_name != "") {
$parts = pathinfo($img1_name);
@copy("$img1", "pictures/$new_name.$parts[extension]")
or die("Couldn't copy the file.");
} else {
die("No input file specified");
}
?>
Posted: Mon Apr 19, 2004 8:11 pm
by feyd
he'll still get .12.(maybe jpg).
he's using a double quoted string, not single quotes.
hward, change those single quotes to double quotes, and it should come out okay..
Posted: Mon Apr 19, 2004 8:13 pm
by Chris Corbyn

Oops. We've been working with $Img all along when we should have been using $Img_name lol
Posted: Mon Apr 19, 2004 8:13 pm
by hward
it seems to be working fine now on all extensions with that last change i just posted
Posted: Mon Apr 19, 2004 8:14 pm
by hward
i took out the periods that I was getting too is that going to cause me any problems
Posted: Mon Apr 19, 2004 8:16 pm
by Chris Corbyn
No, they shouldn't have been there anyway. That was my mistake. You only need them when you're working inside single quotes.