Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





ImageJPEG() - Saving Result From Browser With Filename While Using Sessions


I've created a PHP file called filename.jpg. It outputs a JPG. I've set up
a .htaccess file to force the filetype to PHP. The file is displayed in a
page on a browser. I cannot get the damn thing to save as my suggested
filename or even as anything but a BMP in IE6. I've tried a bunch of
different combinations of the content-type and content-disposition (inline,
attachment, filename, name) headers. Nothing has worked.

I've tried all combinations of the following header() string (regex for
brevity-I didn't actually use the regex characters):

Content-(T|t)ype: image/jpeg(; (file)?name="?xx.jpg"?)?

with and without:
Content-(D|d)isposition: (inline|attachment)(; (file)?name="?xx.jpg"?)?

followed by:
ImageJPEG($im,'',60);

After many hours pounding my head against the wall and RingTFingM, I
realized 2 things as I was writing this post.

The first is that I'm using session_start(). Take it out and I have no
trouble.

The second is that I've encountered this problem before, spent hours on it,
and finally gave up and passed all parameters to the script by $_GET.

I'd rather not do that again. The image is being used as a server-side
image map. Does anyone know how I can use session_start AND the
Content-disposition header? I've tried placing the header before
session_start, to no avail.




View Complete Forum Thread with Replies

Related Forum Messages:
Imagejpeg() [function.imagejpeg]: Unable To Open
i got this problem with a little script im doing. It simply creates a thumbnail on the fly from an image that is uploaded. It works fine on my local testing machine but when i upload it to my server via ftp it doesn't seem to work. This is the error message i get:

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'http://www.mydomainname.com/seanteam/Alistair.jpg' for writing in /home/clovhcom/public_html/seanteam/upload.php on line 180. Here are the snippets of code i think are relevant: Code:

View Replies !
Warning: Imagejpeg() [function.imagejpeg]:
I found this script on the web and all being well it should work. It is an resize image script to work with an upload file script via the include() function.

But I keep getting an error message and I am unable to upload a file, (the file is a jpg called test) would anyone be so kind as to have a look at the scripts and try and determine what might be causing the error.

Here is the error:
Warning: imagejpeg() [function.imagejpeg]: Unable to open 'http://www.mysite.co.uk/php_solutions/test.JPG_thb.jpg' for writing in /home/philweb/public_html/php_solutions/create_thumb.inc.php on line 69

line 69 is this
$success = imagejpeg($thumb, THUMBS_DIR.$name.'_thb.jpg', 100);

Code:

View Replies !
Saving A Result To Another Table
I have a script that will print out the results of a table and make a
calculation of a total of one of the columns. See example:

<?php

/* Database connection */
include(MYSQL_CONNECT_INCLUDE);

/* Select all pilots */
$query = "SELECT * FROM pilots ORDER BY pilot_num ASC";
$result = mysql_query($query);

/* Determine the number of pilots */
$number = mysql_numrows($result);

if ($number > 0) {
/* Print roster header
Change this HTML to fit your webpage layout */
print "<table>";
print "<tr>";
print "<td bgcolor=#000080 width=85 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>NUMBER</b></font></td>";
print "<td bgcolor=#000080 width=120 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>NAME /
EMAIL</b></font></td>";
print "<td bgcolor=#000080 width=130 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>CITY</b></font></td>";
print "<td bgcolor=#000080 width=93 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>COUNTRY</b></font></td>";
print "<td bgcolor=#000080 width=93 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b>FLIGHT
TIME</b></font></td>";
print "<td bgcolor=#000080 width=75 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b><center>STATUS</center></b></font></td>";
print "<td bgcolor=#000080 width=75 height=12
align=left><font face=Arial color=#FFFFFF
size=2><b><center>LOG
BOOK</b></center></font></td>";
print "</tr>";


View Replies !
Saving Result Of Function Without Being Echoed
I am trying to save the function "rand(1, 1000000)" in a variable but when I am for example trying:

$randomnumber = rand(1, 1000000);

it is executing it right ahead while when i try

$randomnumber = "rand(1, 1000000)";

or

$randomnumber = 'rand(1, 1000000)'

It is saving rand(1, 1000000) as variable.

But what I need is a variable saving the result of rand(1, 1000000) so the number does not change either.

Any ideas how I would do this?

View Replies !
Saving Image From Browser
I have a quick script that I wrote to display some images in a gallery format. I wanted to track the views of each image, so instead of directing linking each thumbnail to the larger image, i linked it to a php file which updated a database field and then redirects to the image using headers.


if($_GET['image']){
$id = $_GET['image'];
mysql_query("UPDATE downloads SET downloads= downloads + 1 WHERE id = '$id'");
$sql = mysql_query("SELECT link FROM downloads WHERE id = '$id'");
$row = mysql_fetch_object($sql);
header("Location: " . $row->link);
}

The problem is, after the image is now opened in the browser window, and you go to save it, it doesn't save as the proper image type. In firefox, it will always save as a PHP file, and IE, always a bitmap (when they are jpg's).

View Replies !
Saving Sessions In MYSQL?
If I want to save a users session in a mysql database for later retrieval, what is the best way to do that? Would it be something like this?

$data = serialize ($HTTP_SESSION_VARS);

I looked in the manual, did some searches and this is the best I could come up with.

View Replies !
Saving Object Across Sessions?
I just want to ask if anyone has any experience with saving object across sessions? Is it possible? Because according to the manual, sessions can only store arrays and primitive variables.

View Replies !
Sessions Variables Not Saving
Quick background:

Developed on Windows (apache/mysql, no register globals or other nonsense)
Moved everything to AIX and have the following problem:

Nothing is saved in my session folder. Yes, I've created the directory. Yes, the apache/mysql/php user has write access to that directory.

View Replies !
Sessions Not Saving, Worked On Windows, Not On AIX
Developed on Windows (apache/mysql, no register globals or other
nonsense)
Moved everything to AIX and have the following problem:

Nothing is saved in my session folder.

Yes, I've created the directory. Yes, the apache/mysql/php user has
write access to that directory.

View Replies !
How To Saving Sessions In MySQL Database?
I want to saving sessions in MySQL database? How to use it?

View Replies !
PHP 4 Sessions, Browser
I am experiencing a very strange problem with sessions. My site has session variables which are populated with data based on the users login name and password. I have written some debug code to "watch" the state of the variables during a session. What I am seeing is quite disturbing and I am not sure if it something I am doing wrong or a php bug or browser bug, or a problem with my host etc.

If I hit the site with IE 5.5 I can log in, and get the welcome screen with the users name and the content of the session variables displayed at the bottom of the page. If a collegue of mine tries to log in with IE 5, no name is displayed and naturally nor are the session variables.

However if I look in the /tmp directory on the host a new session file has been created, I can't view it's contents as I don't have sufficient priviledges, but it contains the same number of bytes as the session variable that is create for the user when I log in with IE 5.5. At this stage I can only assume the same data is being place in the session file, but for some reason it is not making it to the browser.

Some more to consider, it does the same for K-Meleon (an open source browser using the Mozilla engine). And the problem does not occur when my collegue is working on the site locally (running apache and PHP on win2k).

View Replies !
Sessions Across Browser Instances?
I've hit a problem with sessions.

If I have a document relying on sessions which has a link target=_blank
then the new window inherits the session from its parent (in IE).

However, if I embed an instance of IE in a VBA form in Excel and click
on the link, the new window doesn't inherit the session.

I have no idea why this should happen at all since both instances of the
browser have access to the same cookies.

Can anyone tell me how to inherit a session like that? I've tried
passing over $PHPSESSID without any success (PHPSESSID is set correctly,
but $_SESSION is empty)

View Replies !
Sessions And New Browser Window
I have declared a session in main window

session_start();
$_SESSION['language']=$choosen;

And then, I'm opening a pop up which calls this variable and try to echo it:

PHP Code:

echo $_SESSION['language'];

But I get simply nothing, I have tried with isset() but it doesn't work...

View Replies !
Mozilla Browser & Sessions
i have one poblem that i cant able to destroy the session in mozilla browser. its working in IE perfectly.Still Session variables is there even after logout the page.But its not happening in IE. here my code Logout.php

<?php
session_start();
session_destroy();
header("Location:login.php");
any one can tell me wts the problem?

View Replies !
Cross Browser Sessions
i have a page that sets sessions after a user submits a form. The form is submitted through https. Then the session is set and redirects the user to a non-ssl encrypted page. This works fine under internet explorer. But when i use firefox, it will not allow me to redirect to the non-ssl page because the session is not set.

View Replies !
How To Share A Variable Between Browser Sessions
I have to share a variable between browser sessions.
One session for example changes the variable, the other sessions must
see the changes (get the new value instead of the original value)
it's not allowed to save the value in a database or to save it into a
file. It must be a kind of global server variable, changeable by every
session.

View Replies !
Sessions And Browser Back Button
I originaly wrote a script that passed variables from script to script via query strings. When I did that, the user was able to use the back button to go back to previous pages and change form inputs. Then I changed my scripts to use session variables to get rid of the long query strings. Now, when the user hits the back button: "Warning Page has Expired" is what they get. Why is that?

View Replies !
Sessions - Close The Browser And Reopen It
I am trying to temp save some data(username, dob, phone, email) of a user when he types it into the form. When the form is submitted the data is utilised properly on the next page.

But when I close the browser and reopen it (session would have been lost by now) and go back to the same page, it should redirect me back to the form as there is no session but it doesnt. But if I go to the main form and try to enter data into form to continue, it will keep reloading the form. See code below: Code:

View Replies !
Sessions - Cant Call This After The Browser Has Been Closed
why the following code only works in the active session as when you create the text file and why I cant call this after the browser has been closed and a user returns (maybe I am missing something because I would think the whole point of being able to saveing session content would be to bring it back later like on a different day or something

function setFields()
{
session_start();
$session = session_id();

$_SESSION[$_REQUEST['id']]=$_REQUEST['action'];
$saveFile = fopen($session.".txt", "w");

fputs($saveFile, session_encode());
fclose($saveFile);
}

function getFields()..................

View Replies !
If A User Closes His Browser, All Sessions Will Be Destroyed ?
how can i check wheter a user closed his browser ?

View Replies !
Content-Disposition: Attachment; Filename='' Suggestst Wrong Filename
I have a script that i use for my downloadable files.
Bu when i try to download a file with IE it suggests a different
filename
than what i wrote in the code.

For example. If i try to download the file 'download.test.zip' it
suggests
'download[1].test.zip' instead.

I i use Mozilla Firefox to download the file it works fine...
And another question: what does the @-character before
require('includes/sys.dbconnect.php') really do? :)

I think i read it somewhere but i cant seem to remember what it
means...



View Replies !
Dynamically Select The Filename From The Referring Filename.
I am creating a website that has a couple Iframes for content. Now the issue is that I am trying to create the iframe so it will dynamically select the filename from the referring filename. For example: x=section1&cat=page&sid1580uafujn3089efg
put the cat value as the filename plus the .php extension outputted to $page so it can be placed in the src="$page" field of the iframe.

View Replies !
ImageJpeg();
The following code works fine if the objective is to simply output an image, not saving it as a file.

**index.php**
<?php
...
$image='something.jpg'
echo "<img src='newimg.php?image=$image' border=&#390;'>";
...?>

**newimg.php**
<?php
Header("Content-type: image/jpeg");
session_start();
$im = imagecreatefromjpeg("$image");
Imagejpeg($im,'',100);
ImageDestroy($im);?>

howeven, if I wish to save the file, and therefor adds the filename variable (in previous example empty)

**newimg.php**
<?php
Header("Content-type: image/jpeg");
session_start();
$im = imagecreatefromjpeg("$image");
Imagejpeg($im,somethingelse.jpg,100);
ImageDestroy($im);?>

the file is saved, but no image is outputted to the browser. now, you might claime that I could just set the img src to "somethingelse.jpg", but how will I then call the file newimg.php? I can't include() it, cause the file includes a headder(), witch must be submittet in the start of the document, so what do I do?

View Replies !
Imagejpeg
I have this small problem with the size of resized image, I have the image wich is 1MB with 1200x1600px and when I resize it to 60x80 the size is 16KB and it's BMP. What I want is to be JPG and then should be about 2KB. Code:

$photo = "myFile.jpg";
list($ow,$oh) = getimagesize($photo);
$nw = 60;
$nh = $oh * $nw / $ow;
$small = imagecreatetruecolor($nw,$nh);
$big = imagecreatefromjpeg($photo);
imagecopyresized($small,$big,0,0,0,0,$nw,$nh,$ow,$oh);
header("Content-type: image/jpeg");
imagejpeg($small);

View Replies !
Exif_image And Imagejpeg
I'm sketching out an application that would automagically do a photo gallery.

As part of this, I want to examine each graphic in the a given directory, look
for an embedded thumbnail and, if present, output it instead of the image.

Version 2... If there is no embedded thumbnail, create one and save it in the
directory.

I have an image from my Sony camera I'm using to test and it does have an
embedded thumbnail. I'm now trying to extract the image and display it
through imagejpeg.

The code fails with

Warning: imagejpeg(): supplied argument is not a valid Image resource

<?
$iname="DSC00527.JPG";
$image = exif_thumbnail($iname, $width, $height, $type);
$type=exif_imagetype($iname);
echo $type;
if ($image!==false) {
imagejpeg($image);
} else {
// no thumbnail available, handle the error here
echo "No thumbnail available";
}
?>

If I replace the call to imagejpeg with

header("Content-type: " .image_type_to_mime_type($type));
echo $image;

I see the thumbnail. $type is 2, which is IMAGETYPE_JPEG.

Is the image resource returned from exif_thumbnail different from the resource
expected by imagejpeg?

What has gone over my head?

View Replies !
Another Imagejpeg Question
Im trying to use this code that I found on php.net to create a thumbnail
from an image but it simply displays a black square.
Anyone can tell me what am I doing wrong?

<?

function ImageCopyResampleBicubic(&$dst, &$src, $dstx, $dsty, $srcx, $srcy,
$w, $h, $zoomX, $zoomY = '') {
if (!$zoomY) $zoomY = $zoomX;
$palsize = ImageColorsTotal($src);
for ($i = 0; $i<$palsize; $i++) {
$colors = ImageColorsForIndex($src, $i);
ImageColorAllocate($dst, $colors['red'], $colors['green'],
$colors['blue']);
}

$zoomX2 = (int)($zoomX/2);
$zoomY2 = (int)($zoomY/2);

$dstX = imagesx($dst);
$dstY = imagesy($dst);
$srcX = imagesx($src);
$srcY = imagesy($src);

for ($j = 0; $j<($h-$dsty); $j++) {
$sY = (int)($j*$zoomY)+$srcy;
$y13 = $sY+$zoomY2;
$dY = $j+$dsty;

if (($sY >= $srcY) or ($dY >= $dstY) or ($y13 >= $srcY)) break 1;

for ($i = 0; $i<($w-$dstx); $i++) {
$sX = (int)($i*$zoomX)+$srcx;
$x34 = $sX+$zoomX2;
$dX = $i+$dstx;

if (($sX >= $srcX) or ($dX >= $dstX) or ($x34 >= $srcX))
break 1;

$c1 = ImageColorsForIndex($src, ImageColorAt($src, $sX,
$y13));
$c2 = ImageColorsForIndex($src, ImageColorAt($src, $sX,
$sY));
$c3 = ImageColorsForIndex($src, ImageColorAt($src, $x34,
$y13));
$c4 = ImageColorsForIndex($src, ImageColorAt($src, $x34,
$sY));

$r = ($c1['red']+$c2['red']+$c3['red']+$c4['red'])/4;
$g = ($c1['green']+$c2['green']+$c3['green']+$c4['green'])/4;
$b = ($c1['blue']+$c2['blue']+$c3['blue']+$c4['blue'])/4;

ImageSetPixel($dst, $dX, $dY, ImageColorClosest($dst, $r, $g,
$b));
}
}
}
header ("content-type: image/jpeg");
$sourceimg = imagecreatefromjpeg ("temp.jpg");
$destimg = imagecreate (211, 300);
ImageCopyResampleBicubic($destimg, $sourceimg, 0, 0, 0, 0, 422,600, 211,
300);
imagejpeg ($destimg);
?>

--

View Replies !
Imagejpeg And Imagepng
According to the PHP manual, imagejpeg and imagepng have a return value of type "int" - but I do not see where it says what the values mean. Can anyone enlighten me?

View Replies !
Imagejpeg To Ftp Wrapper
I get an error message (Warning: imagegif(): Unable to open 'ftp://userass@ftp/image.jpg' for writing in /thumbnail.php on line 22) when i try to set $imgDest to ftp://userass@ftp/
(ftp server supports passive transfere)

function createjpegThumbnail($img, $imgDest, $suffix, $newWidth, $quality = 100){

    // Open the original image.
    $original = imagecreatefromjpeg($img) or die("Error Opening original");
    list($width, $height, $type, $attr) = getimagesize($img);
    
    // new height by ratio
    $ratio= $height / $width;
    $newHeight = $newWidth * $ratio;
    
    // Resample the image.
    $tempImg = imagecreatetruecolor($newWidth, $newHeight) or die("Cant create temp image");
    imagecopyresized($tempImg, $original, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height) or die("Cant resize copy");

    // Create the new file name.
    $newNameE = explode(".", $img);
    $newName = ‘’. $newNameE[0] .‘’. $suffix .‘.’. $newNameE[1] .‘’;
    
    // Save the image.
    imagegif($tempImg, $imgDest.$img, $quality) or die("Cant save image");

    // Clean up.
    imagedestroy($original);
    imagedestroy($tempImg);
    return true;
}

View Replies !
Using ImageJPEG Without Header()
ImageJpeg() can send output directly to the browser or to a file. When sending directly to a browser, the image can be the only thing sent to the browser. Otherwise you will get the Warning: Cannot modify header information - headers already sent by (output started at... error.

I need to display the output of ImageJPEG as part of a page along with other content, not just the only thing on the page. I could write it to a file, but don't want to use this extra step unless I can't find any alternative.

Is there anyway to send the image to the browser along with other normal content?

View Replies !
ImageJPEG Problem
On my previous server, I could use this function in GD :

ImageJPEG ($img_handle, "image.jpg", 75);

However, I moved to another server. Now when I put that code in, my GD script returns errors. However, when I put this code in and upload it to my new server, it works!

ImageJPEG ($img_handle, "", 75);

Problem is, I dearly need to save the image on my website. What should I do?

View Replies !
Attach Imagejpeg To Email
I'm trying to add an imagejpeg result as an attachment of an email.

For creating the email I'm using phpmailer class
(http://phpmailer.sourceforge.net/)
Now I do create an image from a jpeg file for adding some text on it and
then send it to somebody:
here is the code:
$image = "/include/images/model.jpg";
$src = imagecreatefromjpeg($image);
$size = getimagesize($image);
$dst = imagecreatetruecolor($size[0],$size[1]);
$txt_color = ImageColorAllocate ($dst, 0, 0, 0);
ImageString ($dst, 5, 90, 30 ,"my name", $txt_color);
$tempimage = imagejpeg($dst);
if (!$mail->AddstringAttachment($tempimage,"model.jpg"))
echo ("<strong>failure attachment file</strong><br>");

Instead of attachment file, I get the failure attachment file message on the
screen after a lot of text (the jpeg file in text format).

View Replies !
Imagejpeg() Due To Safe Mode?
The following script used to work great. I hadn't used it for a long time and in the meantime I guess, things changed with php (safe mode? etc.).

I get the following error now when trying to scale an image:

Warning: imagejpeg() [function.imagejpeg]: Unable to open '/home/domain/public_html/fileresize/temp/18d7011550ad5fa215d9e089a5aa27aa-image.jpeg' for writing in /home/domain/public_html/fileresize/resizejpg.php on line 90
I searched and found recommendations to use touch();

I tried that and it still doesn't work. So I don't know if I'm putting touch(); in the wrong place, or what else might be wrong. I'm really hoping someone can help get this working again. It's for a non-profit animal rescue website and having the image resize is vital to what I need to accomplish. Code:

View Replies !
Use Php Image Functions ( Imagejpeg();
It would like to know when I use php image functions ( imagejpeg(); , etc) what consumes of the server.

View Replies !
Problem Using GD Library ImageJPEG Function
I just discovered a weird effect in my php code. here is the flow of my
code:

1. upload jepg file to server
2. create new (empty) jpeg file using imagecreatefromjpeg() function
3. use imagecopyresampled to resize src image and store in newly created
image from step 2.
4. use imagejpeg to get new jpeg data
5. store that data in the mysql database

NOW: when i use imagejpeg using 100% image quality, some images in the
database are corrupt, but NOT ALL only some of them.

when i reduce image quality to 60% i had no problem using a picture
which hat problem with 100%. images are ok this way.

does this have some logical explanation? is this a bug in the gd or
something?

I use PHP 5.0.2, GD bundled (2.0.28 compatible), and mysql 4.x

I will analyze that code in more detail...

View Replies !
Call To Undefined Function Imagejpeg()
I tried to create some images with php and gd and get always

Call to undefined function imagejpeg()
or
Call to undefined function imagepng()

PHP was build with --with-gd --with-zlib but I assume I will need more?

phpinfo() says:
gd
GD Support enabled
GD Version bundled (2.0.23 compatible)
GIF Read Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

View Replies !
Image Uploads Problems - Imagejpeg(): Unable To Open....
i have a image upload page that ive been assigned to fix, due to it apparently never working. I have a sneaky suspision that the storage directory for the images has not been set the required permissions. The main problem is that the server we are running the site on does not allow us access to the php.ini. Code:

View Replies !
Imagejpeg - Thumbnail Function Save The Image To An Ftp Server?
How can i make my thumbnail function save the image to an ftp server? .....

View Replies !
How To Determine If The Browser Is An English Browser
need to seperated english traffic from the rest of it. What is the easiest way to do this? get_brower() seems pretty complicated, and from what i here sucks pretty bad!

View Replies !
File_get_contents - Making A Browser Within Browser
im making a browser within browser (dont bother asking why), but the problem is when i use file_get_contents, it works, however, the original HTML doesnt use absolute locations of images etc... so it tries to look for them on my server .

I tried using str_replace to change it but i cant distinguish between things which are relative and absolute references...

View Replies !
Displaying Result 1-8, Then Result 9-17 Etc.
I dispaly the results from the database like this.

<? while ($row = mysql_fetch_array($prod_result)) {
$small = $row[0];
echo"<td align=center><img src="produkter/hardware/decks/$small"></strong></td>";}?>

But if there are more than 8 results, I wnat to dispaly the first 8 on one page, then the next 8 on the next page...How can this be done?

View Replies !
Imagejpeg Generating String Not Image Even With Header("Content-type:image/jpeg")
does anyone know why i can't generate images with:
header("Content-type:image/jpeg");
imagejpeg($img_number);

i've tried different examples but i always get a text output as if the
header doesn't make a difference at all.

<?php
//random_number.php
$img_number = imagecreate(100,50);
$white = imagecolorallocate($img_number,255,255,255);
$black = imagecolorallocate($img_number,0,0,0);
$grey_shade = imagecolorallocate($img_number,204,204,204);

imagefill($img_number,0,0,$grey_shade);
ImageRectangle($img_number,5,5,94,44,$black);
ImageRectangle($img_number,0,0,99,49,$black);

header("Content-type:image/jpeg");
imagejpeg($img_number);
?>

View Replies !
Get Filename From Url
If I have a url such as:
http://www.planetblaze.com/index.htm or
http://forum.maidenfans.com/images/header.jpg

how can i get just the filename from the end? Is there an easy way? I really dont understand reg expressions especially when urls could have any number of dots,, slashes and dashes.

View Replies !
Get .PHP Filename?
I've been looking thru my PHP functions and can't find what I need -
is there a function that will tell me what .php file is currently
executing?

View Replies !
Filename From URL
I have a URL like: www.abcd.com/12345 that give a download of a file xyz.jpg.
how can I get the string "xyz.jpg" from de www.abcd.com/12345

View Replies !
FILENAME
I have a php script, say example.php,

how do i make my script display the filename within the file, so that for example somewhere in the script i have echo "$filename"; the filename is displayed on the screen (my echo script is probably wrong but im rushing this!)

THEN!!! how do i take away the ".php" from the file name and replace it with .html

so that the page example.php echo's example.html
and the page template.php echo's template.html

View Replies !
Filename
I have a temp folder that clients ftp images into. Now if they upload a file called 'White Lilly.jpg' linux adds a backslash to escape the space in the name. so it becomes 'White Lilly.jpg' The problem I am having is once they upload the file, I read the directory for any files inside and rename them, and move them to another folder. Like so


$directory = '../tempimages'
$directory_stream = opendir($directory);
while ($entry = readdir($directory_stream)){
$oldpath = $directory."/".$entry;
$newpath = '../../gallery/'.$imageid.'.jpg'
$cmd = "mv ".$oldpath." ".$newpath;
$ret =0;
exec($cmd, $result, $ret);
}

View Replies !
Fpassthru With Another Filename
Is it possible to open a file, for example "myfile.exe"
and pass i thru with another name, for example "sillyfile.exe"?

I've checked the PHP manual, but I can't see a solution for this?

View Replies !
What Is The Current Filename?
I think I'm missing something obvious, but I didn't spot this searching the PHP.net site.

I just want a php function or variable to tell me the name of the file in which I (the code being interpreted) currently am. The PHP interpreter knows because if there's an error, it displays the exact filename.

In particular, if it's an included file, I want to know its (the included file's) pathname.

View Replies !
Filename Without Extension
i have the below command to make a $file(filename) and a $extension(just the extension), but i am trying to figure out how to add another one to have a variable of just the filename without extension (in addition to the others).

if(is_array($files)){
sort($files);
foreach($files as $file){
$path_parts = pathinfo("$file");
$extension = $path_parts['extension'] ;

View Replies !
PHP Filename Search - Possible?
I have a directory of pdf files

13344.pdf
21488.pdf
etc

Users want to search for a particular pdf file and have that displayed to
them. ie user searches for: 13344

Is it possible for a PHP script on its own to search a folder based on file
name and retrieve the pdf file or will i need to add the files name to a...

View Replies !
Get Filename As Variable
I can get the filename of the PHP document currently being viewed/used to use as a variable? lets say I execute script bob.php, but in it is required/included header.php, which is where I will hopefully be using the above question. Would this give me bob.php or header.php? I want to get bob.php

View Replies !
Filename Parsing....
What I am trying to do is take a filename from a URL
(http://example.com/?i=image-t.jpg) and dynamically re-size it based on
the "-t"

For example, I have an original image that is called "image.jpg"

If someone changes the URL to point to: "image-t.jpg" I want to parse
the "-t", resize it to a thumbnail and display that.

I have the resizing down so no problem there. I just can't wrap my
head around regular expressions.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved