Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old March 25th, 2008, 01:05 PM
bizt
Guest
 
Posts: n/a
Default Problems uploading images with script

Hi,

Im having trouble with my script in the sense that it doesnt appear to
be able to access files uploaded to the temporary folder on the
server. Below is the script that I am using:

<?php

if(isset($_REQUEST['submit_add'])) {

$imgPath = $_FILES['image']['tmp_name']; // the location of the temp
file

// diplay tmp file
print_r($_FILES); echo '<br />';

// does file exists
echo (file_exists($imgPath)) ? 'File exists' : 'File does not
exist'; echo '<br />';

$arDims = getimagesize($imgPath); // function to get image
dimensions etc
print_r($arDims);

}

?><html>
<head>
</head>
<body>
<form method="post" action="test_images.php" enctype="multipart/form-
data">
<input type="file" name="image" />
<input type="submit" name="submit_add" value="Add" />
</form>

</body>
</html>



It is able to provide the location of the uploaded file from the
$_FILES array:

Array (
[image] =Array (
[name] =At the Arch.jpg
[type] =image/pjpeg
[tmp_name] =/var/tmp/phpaHKMQl
[error] =0
[size] =281761
)
)

.... but when I even just do a file_exists on it (/var/tmp/phpaHKMQl ..
is this a lunux path?) returns false. This may be the reason that my
getimagesize() isnt working too.

Can anyone suggest what the problem may be? Is it my script or shoud I
speak with the server guys? Ive tried this on my WAMP setup as well as
another hosting account (possibly Windows) but its only this server
which its not working. Any ideas?

Cheers

Burnsy
  #2  
Old March 25th, 2008, 05:05 PM
Jerry Stuckle
Guest
 
Posts: n/a
Default Re: Problems uploading images with script

bizt wrote:
Quote:
Hi,
>
Im having trouble with my script in the sense that it doesnt appear to
be able to access files uploaded to the temporary folder on the
server. Below is the script that I am using:
>
<?php
>
if(isset($_REQUEST['submit_add'])) {
>
$imgPath = $_FILES['image']['tmp_name']; // the location of the temp
file
>
// diplay tmp file
print_r($_FILES); echo '<br />';
>
// does file exists
echo (file_exists($imgPath)) ? 'File exists' : 'File does not
exist'; echo '<br />';
>
$arDims = getimagesize($imgPath); // function to get image
dimensions etc
print_r($arDims);
>
}
>
?><html>
<head>
</head>
<body>
<form method="post" action="test_images.php" enctype="multipart/form-
data">
<input type="file" name="image" />
<input type="submit" name="submit_add" value="Add" />
</form>
>
</body>
</html>
>
>
>
It is able to provide the location of the uploaded file from the
$_FILES array:
>
Array (
[image] =Array (
[name] =At the Arch.jpg
[type] =image/pjpeg
[tmp_name] =/var/tmp/phpaHKMQl
[error] =0
[size] =281761
)
)
>
... but when I even just do a file_exists on it (/var/tmp/phpaHKMQl ..
is this a lunux path?) returns false. This may be the reason that my
getimagesize() isnt working too.
>
Can anyone suggest what the problem may be? Is it my script or shoud I
speak with the server guys? Ive tried this on my WAMP setup as well as
another hosting account (possibly Windows) but its only this server
which its not working. Any ideas?
>
Cheers
>
Burnsy
>
I've seen this before - the file may or may not actually exist in the
tmp folder. But even if file_exists() fails, it seems
move_uploaded_file() still works.

Try moving it to your own directory then check it out. If it isn't what
you expect, delete it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles