|
I have few urls like
http://www.mydomain.com/statecode1-folder1
http://www.mydomain.com/statecode2-folder1
I want to redirect it to http://www.mydomain.com/folder1/ page but I want to show on browser url the original urls likes
http://www.mydomain.com/statecode1-folder1
http://www.mydomain.com/statecode2-folder1
Please note that I do not have folders statecode1-folder1 and statecode2-folder1
Currently I use the below .htaccess which redirects but it changes the address bar
#Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/ statecode1-folder1 $
RewriteRule ^(.+) / folder1 [L]
RewriteCond %{REQUEST_URI} ^/ statecode2-folder1 $
RewriteRule ^(.+) / folder1 [L]
Thanks in Advance
Regards
Salman Ansari
|
|
|
|
|
Why the below code doesn't upload file to http://xyz.com/uvw/upload_data.php[^] automatically ?
I get error = uploaded file is either missing, empty or was not uploaded via the POST method
But am sure uploading file is not missing or empty as i have echo it and i think i am uploading via post method ?
function datapost($URLServer,$postdata)
{
$agent = "Mozilla/5.0";
$cURL_Session = curl_init();
curl_setopt($cURL_Session, CURLOPT_URL,$URLServer);
curl_setopt($cURL_Session, CURLOPT_USERAGENT, $agent);
curl_setopt($cURL_Session, CURLOPT_POST, 1);
curl_setopt($cURL_Session, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($cURL_Session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL_Session, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($cURL_Session);
return $result;
}
$postdata = array();
$postdata['Id'] = '12340';
$postdata['profileName'] = 'tsunami';
$postdata['file'] = file_get_contents('http://www.abc.co.uk/def/ghi.csv');
$postdata['submit'] = urlencode('submit');
$source= datapost("http://xyz.com/uvw/upload_data.php",$postdata);
Any suggestion devs ??
|
|
|
|
|
Hi,
You need to set CURLOPT_HTTPGET to false explicitly - the PHP documentation doesn't make this clear.
curl_setopt($cURL_Session, CURLOPT_HTTPGET, FALSE);
Niall
|
|
|
|
|
Thanks,
I added the line you said but still getting the same error ..
Anything else i can add/edit to make it working ?
Cheers
|
|
|
|
|
No - that works on my system, as long as the CSV file isn't too big. (OK with 150k, not with 30M)
This is the version of your code I tried out.
<?php
function datapost($URLServer,$postdata)
{
$agent = "Mozilla/5.0";
$cURL_Session = curl_init();
curl_setopt($cURL_Session, CURLOPT_URL,$URLServer);
curl_setopt($cURL_Session, CURLOPT_USERAGENT, $agent);
curl_setopt($cURL_Session, CURLOPT_HTTPGET, FALSE);
curl_setopt($cURL_Session, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($cURL_Session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL_Session, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($cURL_Session);
return $result;
}
$postdata = array();
$postdata['Id'] = '12340';
$postdata['profileName'] = 'tsunami';
$postdata['file'] = file_get_contents('http://localhost/tmp/test.csv');
$postdata['submit'] = urlencode('submit');
$source= datapost("http://localhost/tmp/posthere.php",$postdata);
echo $source;
?>
My test posthere.php is
<?php
foreach($_POST as $k=>$v)
{
echo "$k => ".strlen($v)."<br/>";
}
?>
|
|
|
|
|
Niall Barr wrote: (OK with 150k, not with 30M)
Initially i thought this could be the case as i was uploading around 12mb csv but then i tried with just 4kb but still getting the same error.
I don't really understand what could be the problem - the uploading works fine if i try using normal html form submit but as we don't want to manually browse the file - we decided to go this route and it's not working.. What a pain.
On the other hand why do you say it will not work for size in MB ? Is there any other auto upload way for such big files ?
|
|
|
|
|
I think the only issue was the amount of memory available to PHP on my dev box. I tried with a file that was too big for it.
Are you able to get the other post data transferred if you comment out the file_get_contents line?
Niall
|
|
|
|
|
Niall Barr wrote: Are you able to get the other post data transferred if you comment out the file_get_contents line?
I can't test that as it's some external company site where we have to upload our data so that they can do what they are suppose to do with the data.
Well i use below code as initial request - so they receive the post data and they send us back id which we need to send along with the file -
function datapost($URLServer,$postdata)
{
$agent = "Mozilla/5.0";
$cURL_Session = curl_init();
curl_setopt($cURL_Session, CURLOPT_URL,$URLServer);
curl_setopt($cURL_Session, CURLOPT_USERAGENT, $agent);
curl_setopt($cURL_Session, CURLOPT_POST, 1);
curl_setopt($cURL_Session, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($cURL_Session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL_Session, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($cURL_Session);
return $result;
}
$postdata = array();
$postdata['profileName'] = 'tsunami';
$postdata['tName'] = 'abc';
$postdata['langCode'] = 'en_GB';
... etc
$source= datapost("http://xyz.com/uvw/upload_meta.php",$postdata);
</pre>
It using the same process - so am sure it's only file auto upload bit that's not working for us. As i said it works using normal html form submit.
|
|
|
|
|
It occured to me that it's likely that the site you're posting to expects an attached file rather than the file content in a post field called file...
If that's the case, then this code should work.
<?php
function datapost($URLServer,$postdata)
{
$agent = "Mozilla/5.0";
$cURL_Session = curl_init();
curl_setopt($cURL_Session, CURLOPT_URL,$URLServer);
curl_setopt($cURL_Session, CURLOPT_USERAGENT, $agent);
curl_setopt($cURL_Session, CURLOPT_POST, 1);
curl_setopt($cURL_Session, CURLOPT_POSTFIELDS,$postdata);
$result = curl_exec($cURL_Session);
curl_setopt($cURL_Session, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($cURL_Session, CURLOPT_FOLLOWLOCATION, 1);
return $result;
}
$postdata = array();
$postdata['Id'] = '12340';
$postdata['profileName'] = 'tsunami';
$tmpfile = tempnam(false,'tmp_');
$filedata = file_get_contents("http://localhost/tmp/test.csv");
file_put_contents($tmpfile, $filedata);
$postdata['file'] = "@$tmpfile";
$postdata['submit'] = urlencode('submit');
$source= datapost("http://localhost/tmp/posthere.php",$postdata);
unlink($tmpfile);
echo $source;
?>
|
|
|
|
|
great ... this worked like a charm
Thanks a ton.
|
|
|
|
|
Hi all,
All the while i use to develop PHP app from scratch. Now i thought using standard php framework will be good for better maintenance and support from my teammate. I wonder which PHP framework is good for enterprise application like ZOHO and which php framework is good for normal cms app.
Thanks
|
|
|
|
|
CakePHP is a rapid development PHP framework that provides an extensible architecture for developing, maintaining, and deploying applications. Using commonly known design patterns like MVC and ORM within the convention over configuration paradigm, CakePHP reduces development costs and helps developers write less code.
Hopefully can help you!
Best regards!
Chiry.
|
|
|
|
|
Thanks Chiry, will you recommend Cakephp as well for simple php application development?
|
|
|
|
|
Hi,
Recently there was a problem with my comments posting form, any one post any thing. I want to restrict some of those can any one help me with this. people were misusing this.. were can i find some code ... to restrict some of the options...
www.bharatdesi.com
Thanks in advance...
|
|
|
|
|
Hi,
Can do it in many ways
1. Add captcha image
2. Ask users to first register with the site
3. Set it in a way where the Admin needs to check each and every comment and approve them
Based on which one or a combination you select, the required code will change. Check what CMS are you using in your site. If it is a popular CMS, then there should be plenty of plugins for you to use.
|
|
|
|
|
in addition to what shamly said, I can also add a vote up/down on comments. This allows users to vote down comments that are offensive. Once a comment gets a certain number of down votes to up votes it is hidden, with an option to show it.
This allows your user base to monitor others. Yahoo News uses a system like this.
Chris J
www.redash.org
|
|
|
|
|
I agree with chris. Vote up/down on comments is another option, specially if you have an active community.
|
|
|
|
|
take a look at www.intensedebate.com[^]. very easy javascript plugin, and they seem to have thought of everything.
|
|
|
|
|
I have some xml files that contain quite a lot of data, several hundred, and I would like to be able to extract 3 or 4 named tags from each xml file in a directory. I have a script that can do this but I am a bit confused as to how to execute this. ideally it would be best to have a development environment or other method to convert the script into an exe, but just being able to run the script would be a good start!
cheers!
|
|
|
|
|
navigate to your local directory and at the prompt....
php script_name.php parameter1 parameter2 parameter3
...and so on. the parameters are optional.
To access the variables is like C, look up "php cli" for more info.
This also means your php executable is in the path variable.
Chris J
www.redash.org
|
|
|
|
|
hello Friends,
I have a problem with Google search my domain name is of 2 words and 10 letters http://www.bharatdesi.com
when i search for bharat desi in Google it shows , when i type with no spaces bharatdesi Google shows the results but when i type Bharat or bharat it doesn't show in any of 1 to 50 pages ..
somes websites starts with some other name and ends with bharat they show up in the results ...
Can any one kindly suggest me some reasons or tips
Thanks for your time...
|
|
|
|
|
What you are asking is not PHP related. But the reason you don't show up for just bharat is because your site doesn't have that word in it. All search engines use a very complex algorithm. That is not just based upon Url, but also on incoming links, domain trust levels, page age and to some degree content on the page.
You won't get in the top 10 pages just like that it requires a lot of work. And if you really wanna try you might want to hire a SEO (search engine optimizer) to go through the website you build.
|
|
|
|
|
This is not related to PHP. Anyway, if you are talking about Search Engine Optimization, there are lots of work to do. For internal page relation task please check your page title, meta keyword, meta description and the content. In your case of "Bharat" keywords, please remember to put it into your page title and meta keyword, meta description and the content. External link to your website with "Bharat" as anchor also important. Hope this help, at least some idea for you to start with.
|
|
|
|
|
Hello again everybody. I'm making a network game at the request of a friend of mine and I've run into some trouble. the thing is, in the game-cafe all the computers are networked and i need to send data from one PC to the other. I came onto the solution of using sockets for this, but now I'm in a bit of a complex situation. I need to create the classes for the host computer and the client computer. the client asks for a game while the host listens for connections and accepts them. the problem's are:-
1) When i read the python docs it said that the function socket.bind(address) binds the socket to an address. Is that address on the socket's host or on the client PC?
2) While the socket is listening for connections using the socket.listen(backlog) function, how will it know which connection is from the client PC, so that it can accept that connection?
3) The stupid problem....how exactly do I check the entire network for hosts that are currently listening for connections?
I would be REALLY thankful to anyone who can clear this up for me.
|
|
|
|
|
Hi, shahab96! It is a good question! Did you find out the solution?
|
|
|
|
|