Page 2 of 3
Posted: Sun Jul 08, 2007 8:14 pm
by volka
I suggested to change $_FILES['newLogo']['tmp_name'][name].
I didn't say anything about changing $_FILES['newLogo']['tmp_name'].
There is only one occurence of $_FILES['newLogo']['tmp_name'][name] in your script.
Posted: Sun Jul 08, 2007 9:07 pm
by jiggens
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
So if i change it like so
Code: Select all
if(array_key_exists('uploadNewLogo', $_POST)) {
if ($ID != "" && $ID != "new") {
error_reporting(E_ALL);
ini_set('display_errors', true);
echo "Debug: move_uploaded_file({$_FILES['newLogo']['tmp_name'][name]}, {$uploadfile2} <br />\n";
is_uploaded_file($_FILES['newLogo']['tmp_name'][name]) or die('!is_uploaded_file()');
is_readable($_FILES['newLogo']['tmp_name'][name]) or die('!is_readable(tmp_name)');
is_dir(dirname($uploadfile2)) or die('!is_dir('.dirname($uploadfile2).')');
is_writable(dirname($uploadfile2)) or die('!is_writable('.dirname($uploadfile2).')');
if(move_uploaded_file($_FILES['newLogo']['tmp_name'][name], $uploadfile2)) {
echo "The file ". basename($_FILES['newLogo']['tmp_name'][name]). "has been uploaded";
}else{
echo "There was an error uploading the file, please try again!";
}
createImage($uploadfile2,100,400,'/inetpub/wwwroot/homes/html/images/browse/logos/' . $ID . '.jpg');
createImage($uploadfile2,100,160,'/inetpub/wwwroot/homes/html/images/browse/logos/' . $ID . '-TH.jpg');
unlink($uploadfile2);
}
}
The output is
Notice: Use of undefined constant name - assumed 'name' in D:\Inetpub\wwwroot\html\admin\pshomes\edit-communities.php on line 145
Debug: move_uploaded_file(d, /Inetpub/wwwroot/homes/html/images/temp/avatar60.jpg
Notice: Use of undefined constant name - assumed 'name' in D:\Inetpub\wwwroot\html\admin\pshomes\edit-communities.php on line 147
!is_uploaded_file()
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Sun Jul 08, 2007 9:10 pm
by volka
ehh.... in case you're doing this on purpose: ha ha, not funny.
In case you're serious: $_FILES['newLogo']['tmp_name'][name] wrong, bad $_FILES['newLogo']['tmp_name'][name], no $_FILES['newLogo']['tmp_name'][name]
Start again with the script at
viewtopic.php?p=398686#398686
and replace the only occurence of
$_FILES['newLogo']['tmp_name'][name] by either
$_FILES['newLogo']['tmp_name'] or
$_FILES['newLogo']['name']
Posted: Sun Jul 08, 2007 9:18 pm
by jiggens
Im not doing anything on purpose to upset you or give you hard time, i guess im not getting what your asking me could you show me more what exactlly am i doing wrong?
Did i not put the [name] in the right spots or am i over thinking it.
Posted: Sun Jul 08, 2007 9:22 pm
by superdezign
$_FILES['newLogo']['tmp_name'][name] doesn't exist.
print_r($_FILES['newLogo']) and take a look.
Posted: Sun Jul 08, 2007 9:23 pm
by volka
Please go back to
viewtopic.php?p=398686#398686 and take the script posted there.
Then find the only line that contains $_FILES['newLogo']['tmp_name'][name] there.
Then post that line here.
Posted: Sun Jul 08, 2007 9:32 pm
by jiggens
Yeah this line echo "The file ". basename($_FILES['newLogo']['tmp_name'][name]). "has been uploaded";
Your saying its either tmp name or name but not both
Posted: Sun Jul 08, 2007 9:34 pm
by volka
Yes, now replace $_FILES['newLogo']['tmp_name'][name] in that line, please.
Nothing else, please.
Posted: Sun Jul 08, 2007 9:43 pm
by jiggens
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I changed that one line to ['tmp_name'] and thats it
Debug: move_uploaded_file(d:\Inetpub\wwwroot\temp\php170.tmp, /Inetpub/wwwroot/homes/html/images/temp/avatar60.jpg
The file avatar60.jpghas been uploaded
Code: Select all
if(array_key_exists('uploadNewLogo', $_POST)) {
if ($ID != "" && $ID != "new") {
error_reporting(E_ALL);
ini_set('display_errors', true);
echo "Debug: move_uploaded_file({$_FILES['newLogo']['tmp_name']}, {$uploadfile2} <br />\n";
is_uploaded_file($_FILES['newLogo']['tmp_name']) or die('!is_uploaded_file()');
is_readable($_FILES['newLogo']['tmp_name']) or die('!is_readable(tmp_name)');
is_dir(dirname($uploadfile2)) or die('!is_dir('.dirname($uploadfile2).')');
is_writable(dirname($uploadfile2)) or die('!is_writable('.dirname($uploadfile2).')');
if(move_uploaded_file($_FILES['newLogo']['tmp_name'], $uploadfile2)) {
echo "The file ". basename($_FILES['newLogo']['name']). "has been uploaded";
}else{
echo "There was an error uploading the file, please try again!";
}
createImage($uploadfile2,100,400,'/homes/html/images/browse/logos/' . $ID . '.jpg');
createImage($uploadfile2,100,160,'/homes/html/images/browse/logos/' . $ID . '-TH.jpg');
unlink($uploadfile2);
}
}
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Sun Jul 08, 2007 9:44 pm
by volka
It's working then.
Posted: Sun Jul 08, 2007 9:50 pm
by jiggens
but its not working , i dont see the file uploaded to the server anywhere
Posted: Sun Jul 08, 2007 9:58 pm
by volka
hm, then move_uploaded_file() must be lying to you
..I doubt that

please try
Code: Select all
if(move_uploaded_file($_FILES['newLogo']['tmp_name'], $uploadfile2)) {
echo "<div>The file ". basename($_FILES['newLogo']['name']). "has been uploaded.</div>";
echo '<div>Location: ', realpath($uploadfile2), '</div>';
echo is_readable($uploadfile2) ? 'r':'-',
is_writable($uploadfile2) ? 'w':'-',
is_executable($uploadfile2) ? 'w':'-', "</div>\n";
echo '<div>filesize: ', filesize($uploadfile2), "</div>\n";
$fp = fopen($uploadfile2, 'rb');
echo '<div>first 50 bytes: ', fread($fp, 50), "</div>\n";
}
else{
echo "There was an error uploading the file, please try again!";
}
Posted: Sun Jul 08, 2007 10:01 pm
by jiggens
Debug: move_uploaded_file(d:\Inetpub\wwwroot\temp\php185.tmp, /Inetpub/wwwroot/homes/html/images/temp/avatar60.jpg
The file avatar60.jpghas been uploaded.
Location: D:\Inetpub\wwwroot\homes\html\images\temp\avatar60.jpg
rw-
filesize: 4838
first 50 bytes: ÿØÿà�JFIF��–�–��ÿþ�LEAD Technologies Inc. V1.
Warning: unlink(/Inetpub/wwwroot/homes/html/images/temp/avatar60.jpg) [function.unlink]: Permission denied in D:\Inetpub\wwwroot\html\admin\pshomes\edit-communities.php on line 166
Posted: Sun Jul 08, 2007 10:03 pm
by volka
You see the file was/is there.
The open file handle prevented your unlink() from removing the file so you should find a file D:\Inetpub\wwwroot\homes\html\images\temp\avatar60.jpg now.
Posted: Sun Jul 08, 2007 10:14 pm
by jiggens
yep its there.
but i now need my functions to work ?
Could you help me with those ?
it takes 1 image and creates 2 of them and resizes both.