views:

134

answers:

4

I uploaded 1 file and name it "test-test-test-test-test.php". It create problem in my layout. my layout is mess up. so if i upload file name up to 10 char then its fine.

+1  A: 

Rename it before uploading.

In PHP:

<?php
$filename = 'test-test-test-test-test.php';
rename($filename, substr($filename, 0, 10) . '.php'));
?>
fabrik
its CCK file field in drupal.i cant do like this.bcoz when i click on node view it has to be full view but on home page display only its trimmed.
dayana
Then second option is yours. Trim filename as i wrote. Note: you'll need to take care about paths.
fabrik
i found the solution my self..
dayana
A: 
$filename = 'testtesttesttesttesttest.php'; 
$filename = basename($path, ".php");
$filename = substr($filename, 0, 10);
$filename .= '.php';
Alexander.Plutov
its CCK file field in drupal.i cant do like this.bcoz when i click on node view it has to be full view but on home page display only its trimmed.
dayana
+1  A: 

Single line solution

<?
$filename="test.php";
$filename=str_pad(trim($filename), 10, "123456789", STR_PAD_LEFT);
echo $filename;
//12test.php
$filename="test.php";
$filename=str_pad(trim($filename), 14, "123456789", STR_PAD_LEFT);
echo $filename;
//123456test.php
?>
JapanPro
A: 

I found the solution. Its using jquery.

jQuery("div.files .view-content .views-field-field-file-file-fid .filefield-file a") .each(function(){ var file_text = jQuery(this).text(); if(file_text.length > 10){ file_sub_text = file_text.substring(0,10); jQuery(this).text(file_sub_text+ "..."); } });

dayana