使用PHP接收数据或字符串[关闭]

update images to server using php called a.php.If I want to post some strings,can I use the same php,or I need create a new one.

this is the a.php excerpt:

<?php

$con=mysql_connect("localhost","root","wk123456");
mysql_select_db("update",$con);
if($_FILES['uploadedfile']['size']>0)
{
$fileName=$_FILES["uploadedfile"]["name"];
$tmpName=$_FILES["uploadedfile"]["tmp_name"];
$fp=fopen($tmpName,'r');
$content=fread($fp,filesize($tmpName));
$content=addslashes($content);
fclose($fp);
...
mysql_close($con);
?>

You can use the same PHP. Just add another input field to your form and you can access it via the regular $_GET or $_POST way.

For uploading images or file types you need to mention enctype in your form

<form action="upload_file.php" method="post" enctype="multipart/form-data"> . Other wise upload will not work.

Also you need to use $_FILES to get the uploaded files details. $_POST will not give the uploaded file values.

So you can use $_FILES['fieldname']['name'] like that.

For more details refer this