Rectangle 27 3

That solution applies, in the abstract, to PHP as well.

The way you detect a link target's content type is by performing an HTTP HEAD request (such as with the curl extension for PHP, or the get_headers function) and then reading the returned Content-Type header.

Make sure to fail gracefully if the remote end is inaccessible.

note that get_headers will do a GET request unless you change the method via a custom stream context

Detect link content type with PHP - Stack Overflow

php content-type
Rectangle 27 6

To remove a content type from search you can use the search configuration module. http://drupal.org/project/search_config

php - how can i exclude one content type from drupal search - Stack Ov...

php drupal drupal-6 drupal-modules
Rectangle 27 5

$this->RequestHandler->respondAs('xml')

The PHP way is to issue header('Content-Type: text/xml') anywhere before any output (usually somewhere in the controller).

php - How to write content type in cakephp? - Stack Overflow

php http cakephp header content-type
Rectangle 27 5

$this->RequestHandler->respondAs('xml')

The PHP way is to issue header('Content-Type: text/xml') anywhere before any output (usually somewhere in the controller).

php - How to write content type in cakephp? - Stack Overflow

php http cakephp header content-type
Rectangle 27 2

Googling a little found me this:

You then can read the "content-type" header entry.

note that get_headers will do a GET request unless you change the method via a custom stream context

Detect link content type with PHP - Stack Overflow

php content-type
Rectangle 27 8

You can specify the type in the parameters like this:

$fileUploadPostParams = array(
    "uploadedfile" => "@/files.jpg;type=image/jpeg"
);

-F accepts parameters like -F "name=contents". If you want the contents to be read from a file, use <@filename> as contents. When specifying a file, you can also specify the file content type by appending ';type='

"uploadedfile" => "@/files.jpg;type=image/jpeg;filename=custom_name.jpg"

curl - How can I modify content type of uploaded file in php? - Stack ...

php curl mime-types
Rectangle 27 2

Maybe you should have a look at Features module. Using Features should allow you to export your content type along with added fields into a module you can install to another site later.

Thanks a lot, thats what I need :)

php - Convert drupal 7 content type into code automatically. Content t...

php drupal drupal-7 drupal-modules drupal-content-types
Rectangle 27 6

I believe the table you are looking for is file_managed (Drupal 7) or files (Drupal 6). This will give you paths to the uploaded images.

php - Where does drupal saves images path i've uploaded from a content...

php drupal
Rectangle 27 1

get_headers - and check for Content-type header.

note that get_headers will do a GET request unless you change the method via a custom stream context

Detect link content type with PHP - Stack Overflow

php content-type
Rectangle 27 2

per https://stackoverflow.com/a/25998544/1067003 , libcurl has no built-in mechanism to encode requests as multipart/related (and this guy is the author and main developer of curl, so he'd know) meaning that you have to encode the body yourself.

i don't have access to a server to test on, but i think it would go something like this:

<?php
declare(strict_types = 1);
$files = array (
        new MultipartRelatedFile ( 'foo.php' ),
        new MultipartRelatedFile ( 'bar.php' ),
        new MultipartRelatedFile ( 'baz.php' ) 
);
$body = generateMultipartRelatedBody ( $files, $boundary );
$ch = curl_init ();
curl_setopt_array ( $ch, array (
        CURLOPT_HTTPHEADER => array (
                'Content-Type: multipart/related; boundary="' . $boundary.'"' 
        ),
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $body,
        CURLOPT_URL => 'http://127.0.0.1:9999' 
) );
curl_exec ( $ch );
class MultipartRelatedFile {
    public $path;
    public $postname;
    public $content_type;
    function __construct(string $path) {
        if (! is_readable ( $path )) {
            throw new \Exception ( 'file is not readable!' );
        }
        $this->path = $path;
        $this->content_type = mime_content_type ( $path );
        $this->postname = basename ( $path );
    }
}
/**
 * generate http body for a multipart/related POST request
 *
 * @param MultipartRelatedFile[] $files
 * @param string|null $boundary
 */
function generateMultipartRelatedBody(array $files, string &$boundary = NULL): string {
    if (null === $boundary) {
        $boundary = bin2hex ( random_bytes ( 10 ) );
    }
    $n = "\r\n";
    $body = '';
    foreach ( $files as $file ) {
        $body .= $boundary . $n;
        $body .= 'Content-Disposition: attachment; filename=' . $file->postname . $n;
        $body .= "Content-Type: " . $file->content_type . $n;
        $body .= $n . file_get_contents ( $file->path ) . $n;
    }
    $body .= $boundary . '--';
    return $body;
}

warning: short of making sure it looks correct-ish in a netcat server, this is untested code.

Content-Length
Content-Id
Content-Disposition
start

edit: forgot to add quotes (") around the boundary of the initial Content-Type header, fixed.

curl - How to send “multipart/related” content type in PHP - Stack Ove...

php curl mime multipart
Rectangle 27 2

You can make a module which will create a content type on installation. You can take help of this documentation on drupal.org. A small tutorial is available here too..

Next thing you will want to insert data pro-grammatically & here is the help - Inserting & Updating Node Programmatically

I know it's takes time to start and sometime to make it run but at-least you are willing to start now. So happy coding with Drupal..GOOD LUCK :)

php - Programmatically create new content type with fields in Drupal 6...

php mysql drupal drupal-6
Rectangle 27 3

I also ran into this problem, and as the author pointed out, this is the way to fix it using the s3cmd tool:

s3cmd --recursive modify                             \ 
    --acl-public                                     \
    --add-header='Cache-Control: max-age=94608000'   \
    --add-header='content-type':'audio/mpeg'         \
    --exclude '' --include '.mp3'                    \
    s3://<your-bucket-name>/                         \

The --recursive modify flag tells s3cmd to recuse into your bucket and find all files to modify; --acl-public opens modified files for public access; --add-header='Cache-Control sets the amount of time in seconds the cache can keep the file (so people getting the file from your bucket won't need to download it a second time, if the file hasn't changed). --exclude '' --include 'mp3' instructs s3cmd to exclude all files from the process, except the ones matching the specified pattern. Here is another example, setting all css files in your bucket to text/css:

s3cmd --recursive modify --add-header='content-type':'text/css' \
      --exclude '' --include '.css' s3://<your-bucket-name>/
content-type

This solution worked for me. One thing to note: If you're storing sensitive data, I'd suggest adding --encrypt as well to use S3 server side encryption.

php - How can i change AWS S3 content type only for audio files - Stac...

php amazon-web-services amazon-s3
Rectangle 27 2

curl_error
https
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_CAINFO, getcwd() . "/CAcerts/your_certificate.crt");
  • Browse url in firefox browser

http - Content Type not being set in cURL in PHP - Stack Overflow

php http curl header content-type
Rectangle 27 3

You can do that using field_delete_instance()

php - Programmatically, I want a Drupal 7 content type with no "body" ...

php drupal drupal-7 field content-type
Rectangle 27 3

Using new sdk, one can set the content type as follows(i have set the content type for gif image in this example).

$blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString);
//upload
$blob_name = "image.gif";
$content = fopen("image.gif", "r");

$options = new CreateBlobOptions();
$options->setBlobContentType("image/gif");
try {
    //Upload blob
    $blobRestProxy->createBlockBlob("containername", $blob_name, $content, $options);
    echo "success";
} catch(ServiceException $e){
    $code = $e->getCode();
    $error_message = $e->getMessage();
    echo $code.": ".$error_message."<br />";
}

azure: Set blob content type using PHP - Stack Overflow

php azure blob contenttype
Rectangle 27 4

The Field Permissions module allows site administrators to set field-level permissions to edit, view and create fields on any entity.

php - How can I allow only specific users to view specific fields of a...

php drupal drupal-7 drupal-modules entityreference
Rectangle 27 2

Content types do not have the body field by default - it is usually added when creating the content type:

// add content types
$ctypes = _my_module_get_content_types();          // get content types
foreach($ctypes as $ctype => $data){
  if (!in_array($ctype, node_type_get_names())) {  // check for collisions
    $data = node_type_set_defaults($data);         // default *does not* add body field
    node_type_save($data);
    node_add_body_field($data);                    // add body here (typical usage)
  }
}
node_add_body_field()

php - Programmatically, I want a Drupal 7 content type with no "body" ...

php drupal drupal-7 field content-type