ccrevcypsys Posted November 26, 2007 Share Posted November 26, 2007 When ever i try to upload an image it wont work. I beleve it isnt finding any thing for the $_FILES tag. Heres the code: $data['screenname'] = $db->mySQLSafe($_POST['screenname']); if(is_array($_FILES['cust_image'])){ $date_str=date('Ymd'); $imageFormat = strtoupper(ereg_replace(".*\.(.*)$","\\1",$_FILES['cust_image']['name'])); if($imageFormat == "JPG" || $imageFormat == "JPEG" || $imageFormat == "PNG" || ($imageFormat == "GIF" && $config['gdGifSupport']==1)){ if(file_exists("images/uploads/customer_images/".$ccUserData[0]['cust_image'])){ @chmod("images/uploads/customer_images", 0775); @unlink($ccUserData[0]['cust_image']); } copy($_FILES['cust_image']['tmp_name'],"images/uploads/customer_images/".$date_str."_".str_replace('-','_',str_replace(' ','_',$_FILES['cust_image']['name']))); $data["cust_image"] = $db->mySQLSafe("images/uploads/customer_images/".$date_str."_".str_replace('-','_',str_replace(' ','_',$_FILES['cust_image']['name']))); } }else{ echo $_POST['cust_image']." ".$_FILES['cust_image']['name']." - FAIL" ; } $where = "customer_id = ".$ccUserData[0]['customer_id']; $updateAcc = $db->update($glob['dbprefix']."customer",$data,$where); -------Form Code------- <form action="index.php?act=profile{VAL_EXTRA_GET}" target="_self" method="post"> <table border="0" cellspacing="0" cellpadding="3" align="center"> <tr> <td align="right"><strong>{TXT_SCREENNAME}</strong></td> <td><input name="screenname" type="text" class="textbox" id="screenname" value="{VAL_SCREENNAME}" maxlength="100" /></td> </tr> <tr> <td align="right"><strong>{TXT_IMAGE}</strong></td> <td><input type="file" name="cust_image" /></td> </tr> </table> The screenname will upload but the image is not working... Whats wrong with it i have no clue Quote Link to comment Share on other sites More sharing options...
xyn Posted November 26, 2007 Share Posted November 26, 2007 instead of copy(); try http://php.net/move_uploaded_file Quote Link to comment Share on other sites More sharing options...
ccrevcypsys Posted November 26, 2007 Author Share Posted November 26, 2007 the problem is it doesnt get that far... the $_FILES['cust_image'] is not working. It will not let the script run properly... Quote Link to comment Share on other sites More sharing options...
rlindauer Posted November 26, 2007 Share Posted November 26, 2007 Your form tag is incorrect, you have to add an enctype attribute to it: <form action="index.php?act=profile{VAL_EXTRA_GET}" target="_self" method="post" enctype="multipart/form-data"> The enctype attribute of the FORM element specifies the content type used to encode the form data set for submission to the server. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.