note 111978 modified in function.curl-setopt by mazzanet

From: Date: Fri, 19 Apr 2013 05:02:28 +0000
Subject: note 111978 modified in function.curl-setopt by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-194555@lists.php.net to get a copy of this message
I spent a couple of days trying to upload a file using a curl post. The problem I ran into was the filename had an '@' in the middle of it. It turned out that at least on my system if I encoded the file path using the quoted_printable_encode() function the upload works. I'm posting this in the hopes that it will help someone else, and for my own future reference. Code: <?php $filepath = '/tmp/test@example.txt'; $postdata['file'] = '@' . quoted_printable_encode($filepath); //... supporting code. $result = curl_exec($ch); ?> I'm not exactly sure why this works when escaping the '@' doesn't work but it does for me. If anyone can offer insight into why this works or a better way to handle the '@' symbol in a filename when using curl to upload I would love to hear it. Thanks --was-- I spent a couple of days trying to upload a file using a curl post. The problem I ran into was the filename had an '@' in the middle of it. It turned out that at least on my system if I encoded the file path using the quoted_printable_encode() function the upload works. I'm posting this in the hopes that it will help someone else, and for my own future reference. Code: <?php $filepath = '/tmp/test@example.txt'; $postdata['file'] = '@' . quoted_printable_encode(); //... supporting code. $result = curl_exec($ch); ?> I'm not exactly sure why this works when escaping the '@' doesn't work but it does for me. If anyone can offer insight into why this works or a better way to handle the '@' symbol in a filename when using curl to upload I would love to hear it. Thanks http://php.net/manual/en/function.curl-setopt.php

« previous php.notes (#194555) next »