Jump to content

[SOLVED] $_FILES problem


ccrevcypsys

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/78970-solved-_files-problem/
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/78970-solved-_files-problem/#findComment-399682
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.