Re: Image / file uploader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change to double quotes for the HTML portion.

action=\"$_SERVER['PHP_SELF']\"

> When I put single quotes in the PHP_SELF and I get this error:
> Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting T_STRING or T_VARIABLE or T_NUM_STRING
>
> and I can't use double quotes because its in an echo statement.  What
> am I missing?
> echo ("<form method='post' action='$_SERVER['PHP_SELF']'
> encType='multipart/form-data'>
>
> Any more thoughts?
> CH
> __________________________________
> Craig Hoffman - eClimb Media
>
> v: (847) 644 - 8914
> f: (847) 866 - 1946
> e: choffman@xxxxxxxxxxxxxxx
> w: www.eclimbmedia.com
> _________________________________
> On Apr 29, 2004, at 6:49 PM, Daniel Clark wrote:
>
>> I think you want single quotes around PHP_SELF.
>>
>> "$_SERVER['PHP_SELF']"
>>
>>> I have a script where it uploads a image to directory.   I have used
>>> the script several times and it works when I send the form to another
>>> page.  The problem is I have changed the form to submit to itself and
>>> I
>>> can't seem to get it to work.
>>>
>>> echo (" <form method='post' action='$_SERVER[PHP_SELF]'
>>> encType='multipart/form-data'>");
>>>
>>> The thing is all my other fields update except for the image.
>>> Further,
>>> the image does not even show up if I echo the query out.
>>>
>>> UPDATE users SET bio = 'Bio - Test', goals = 'Goals - Test', fav_race
>>> =
>>> 'Fav Races - test', fav_train = 'Traing -test', photo_name = '' WHERE
>>> user_id = '1'
>>> Here is the code of the image uploader and my query, perhaps someone
>>> could take a look let me know what I'm missing.
>>> Thanks - CH
>>>
>>> <input type='file' name='photo'>
>>>
>>> if($_POST["postback_bio"])
>>> 	{
>>>
>>> 	include "include/dbadmin.php";
>>>
>>> 	//image uploader
>>> 	$uploadpath = '/images/clients/';
>>>
>>> 	$source = $HTTP_POST_FILES['photo']['tmp_name'];
>>> 	$photo_name = $HTTP_POST_FILES['photo']['name'];
>>> 	$dest = '';
>>> 	if (($source != '') && ($source != '')) {
>>> 		$dest = $uploadpath.$photo_name;
>>> 		if ($dest = '') {
>>> 			if (move_uploaded_file($source, $dest)) {
>>> 				echo ("<p id='message'>Image and Bio has been successfully
>>> stored.</p> ");
>>> 			} else {
>>> 				echo ("<p id='message'>Image could not be stored.</p>");
>>> 			}
>>> 		}
>>> 	} else {
>>> 		echo ("<p id='message'>No new image supplied.</p>");
>>> 		$photo_name = $oldimage;
>>> 		}
>>>
>>> 		//declare varibles
>>> 		$user_id = $_POST["user_id"];
>>> 		$name = $_POST["name"];
>>> 		$bio = $_POST["bio"];
>>> 		$goals = $_POST["goals"];
>>> 		$fav_race = $_POST["fav_race"];
>>> 		$fav_train = $_POST["fav_train"];
>>> 		$photo = $_POST["photo_name"];
>>>
>>> 	$query = "UPDATE users SET bio = '$bio', goals = '$goals', fav_race =
>>> '$fav_race', fav_train = '$fav_train', photo_name = '$photo_name'
>>> WHERE user_id = '$user_id'";
>>> 	echo $query;
>>> 	$msg = "<span style='color:red' id='message'>Could not update
>>> record</span>";
>>> 	$result = mysql_query($query, $db);
>>>
>>> 	}
>>>
>>>
>>> __________________________________
>>> Craig Hoffman - eClimb Media
>>>
>>> v: (847) 644 - 8914
>>> f: (847) 866 - 1946
>>> e: choffman@xxxxxxxxxxxxxxx
>>> w: www.eclimbmedia.com
>>> _________________________________
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux