Forum Moderators: coopster

Message Too Old, No Replies

Not quite sure...

My upload script seems to work for the imagevar1 but not for imagevar2 etc

         

PSWorx

4:28 am on Nov 13, 2003 (gmt 0)

10+ Year Member



Quite simply, i have a form, in this form are some vars for updating a database and also for uploading an image, at the moment im testing the outputs of the vars for the image upload, seems to work fine (using: echo"Image to up: $GLOBALS[$imagetoup]"; to access the content) altho only for the first image upload variable (imagevar1), when i test it with the other vars (imagevar2, imagevar3 etc) the output of the echo statement is "none" as opposed to "C:\WINDOWS\phpDF.tmp" being the temp upload dir, don't know if the code will help but here it is:

The Form
--------

function prntpgnm($details,$showbox,$id,$btg,$itu){
global$PHP_SELF;
echo"\n<form action=\"$PHP_SELF\" method=\"POST\" id=\"dispbox\" enctype=\"multipart/form-data\">\n<input type=\"submit\" value=\"Update\" name=\"update\" id=\"button4\">&nbsp;&nbsp;<input type=\"submit\" value=\"Add New Item\" name=\"addnew\" id=\"button4\"><hr align=\"center\" noshade size=\"1\" color=\"#B78C8C\">\n";
$dbuser="****xx";
$dbpass="xxxxx";
$db="database";
$link=mysql_connect("localhost",$dbuser,$dbpass);
mysql_select_db($db,$link);
$dbresult=mysql_query("SELECT * FROM table");
while($field=mysql_fetch_array($dbresult)){
if($field[id]>="1"){echo"\n<hr align=\"center\" noshade size=\"1\" color=\"#B78C8C\">\n";}
echo"<b id=\"loginhead2\">Item ID:</b> $field[id]<br>\n";
echo"<b id=\"loginhead2\">Show:</b>";
echo"<input type=\"radio\" id=\"loginhead2\" value=\"1\" name=\"showbox$field[id]\"";
if(!$field[showbox]=="0"){echo" CHECKED";}echo">On";
echo"<input type=\"radio\" id=\"loginhead2\" value=\"0\" name=\"showbox$field[id]\"";
if(!$field[showbox]=="1"){echo" CHECKED";}echo">Off";
echo"&nbsp;¦&nbsp;Status:";
if(!$field[showbox]==0){echo"<b id=\"on\"> On</b>&nbsp;¦&nbsp;";}else{echo"<b id=\"off\"> Off</b>&nbsp;¦&nbsp;";}
echo"<input type=\"submit\" value=\"Remove\" name=\"remove\" id=\"button3\"><input type=\"radio\" value=\"$field[id]\" name=\"btg\"><br>";
echo"<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr><td valign=\"top\">";
echo"<textarea rows=\"15\" cols=\"45\" id=\"loginhead2\" name=\"details$field[id]\">$field[details]</textarea></td>";
echo"<td width=\"150\" align=\"center\"><div id=\"dispbox\"><a href=\"images/aucitems/$field[itempic]\" target=\"_blank\"><image src=\"images/aucitems/$field[itempic]\" border=\"0\" width=\"212\" height=\"212\"></a></div>";
echo"\n<input type=\"file\" name=\"itemimage$field[id]\"><input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"102400\"><div align=\"left\"><input type=\"submit\" value=\"Add image\" name=\"userimage\" id=\"button3\"><input type=\"radio\" value=\"$field[id]\" name=\"itu\"></div>";
echo"</td></tr></table>";}
echo"<hr align=\"center\" noshade size=\"1\" color=\"#B78C8C\"><input type=\"hidden\" name=\"editaucitems\" value=\"result\"><input type=\"submit\" value=\"Update\" name=\"update\" id=\"button4\">&nbsp;&nbsp;<input type=\"submit\" value=\"Add New Item\" name=\"addnew\" id=\"button4\"></form>";}

The Image Upload Function (This just outputs the vars for now):

function uploadimage($itu){
global$PHP_SELF;
$imagetoup="itemimage$itu";
echo"itu var: $itu<br>";
echo"imagetoup var: $imagetoup<br>";
echo"Image to up: $GLOBALS[$imagetoup]<br>";}

As i say it works for the first image var and outputs the temp dir, so im sure that if i applied the copy() function it would transfer the picture to the set dir, but it doesnt work for the rest, The submit to upload is individual to each image/box set (i.e. one at a time)

Any ideas, im a bit lost with it...

(Sorry about the mess)

PSWorx

9:58 am on Nov 13, 2003 (gmt 0)

10+ Year Member



Forget that last post, not that anyone looked... it seems that my script, or php doesnt like the jpg's uploaded, the thing works fine with any other file type other than jpeg/jpg so ill just have to find a work around for it.

coopster

10:48 am on Nov 13, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



If you are trying to manipulate or work with the images using PHP Image functions [us2.php.net], you may want to read more about them. Particularly the version of PHP you are running and the supported image types.

GD and PHP may also require other libraries, depending on which image formats you want to work with. You may wish to enhance GD to handle more image formats (including jpeg/jpg).

PSWorx

12:16 pm on Nov 13, 2003 (gmt 0)

10+ Year Member



Well firstly the problem i initialy outlined was solved with something quite simple, i had set the max file size (in a hidden input field) as 100k instead of 1mb, so changing this to 1mb now allows for the vars to be assigned with values, thus intentionaly allowing for the image to be uploaded altho this isnt the case as im finding out and i dont quite know why as ive taken the copy function from a WORKING script that i wrote my self, anyways im not even gonna bother going into that, i dont have 4 hours to wait for any form of answer and even then i tend to figure it out before anyones replied so erm, happy hunting i suppose, but thanks coop for ur info i might look into it when ive got the time, but not just yet.

Laters