473,399 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

move_uploaded_file on localhost

Hi,
The code below is working - it returns the 'Received' message, however
I cannot find the uploaded file in the destination folder, or anywhere
else (other than source directory). I'm running PHP 5.2.5 on my PC
running Apache 2.0. Thanks.

<?php
$uploadDir = "/uploads";
$temp = $uploadDir;

if(is_uploaded_file($_FILES['upfile']['tmp_name']))
{
}
else
{
echo "the file was not uploaded correctly, try again";
exit(0);
}

if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
print "Received {$_FILES['upfile']['name']} - its size is
{$_FILES['upfile']['size']}";
else
{
echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
$uploadDir";
exit(0);
}
?>
Apr 8 '08 #1
3 7538
groupie wrote:
Hi,
The code below is working - it returns the 'Received' message, however
I cannot find the uploaded file in the destination folder, or anywhere
else (other than source directory). I'm running PHP 5.2.5 on my PC
running Apache 2.0. Thanks.

<?php
$uploadDir = "/uploads";
$temp = $uploadDir;

if(is_uploaded_file($_FILES['upfile']['tmp_name']))
{
}
else
{
echo "the file was not uploaded correctly, try again";
exit(0);
}

if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
print "Received {$_FILES['upfile']['name']} - its size is
{$_FILES['upfile']['size']}";
else
{
echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
$uploadDir";
exit(0);
}
?>
You should find your file in your root directory, it will be named
'uploads'.

To solve your problem, you should add a filename to the destination
part, like:
move_uploaded_file($_FILES["upfile"]["tmp_name"],
$uploadDir.$_FILES["upfile"]["name"] );

best regards
Piotr Nastaly
Apr 8 '08 #2
Piotr wrote:
groupie wrote:
>Hi,
The code below is working - it returns the 'Received' message, however
I cannot find the uploaded file in the destination folder, or anywhere
else (other than source directory). I'm running PHP 5.2.5 on my PC
running Apache 2.0. Thanks.

<?php
$uploadDir = "/uploads";
$temp = $uploadDir;

if(is_uploaded_file($_FILES['upfile']['tmp_name']))
{
}
else
{
echo "the file was not uploaded correctly, try again";
exit(0);
}

if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
print "Received {$_FILES['upfile']['name']} - its size is
{$_FILES['upfile']['size']}";
else
{
echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
$uploadDir";
exit(0);
}
?>

You should find your file in your root directory, it will be named
'uploads'.

To solve your problem, you should add a filename to the destination
part, like:
move_uploaded_file($_FILES["upfile"]["tmp_name"],
$uploadDir.$_FILES["upfile"]["name"] );

best regards
Piotr Nastaly
Ofc, i forgot to add directory separator
move_uploaded_file($_FILES["upfile"]["tmp_name"],
$uploadDir . DIRECTORY_SEPARATOR . $_FILES["upfile"]["name"] );
Apr 8 '08 #3
On Apr 8, 9:38*pm, Piotr <s...@poczta.onet.plwrote:
Piotr wrote:
groupie wrote:
Hi,
The code below is working - it returns the 'Received' message, however
I cannot find the uploaded file in the destination folder, or anywhere
else (other than source directory). I'm running PHP 5.2.5 on my PC
running Apache 2.0. Thanks.
<?php
* $uploadDir = "/uploads";
* $temp = $uploadDir;
if(is_uploaded_file($_FILES['upfile']['tmp_name']))
{
}
else
{
* *echo "the file was not uploaded correctly, try again";
* *exit(0);
}
if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $uploadDir ))
* * * * print "Received {$_FILES['upfile']['name']} - its size is
{$_FILES['upfile']['size']}";
else
{
* *echo "error moving file from ".$_FILES["upfile"]["tmp_name"]." to
$uploadDir";
* *exit(0);
}
?>
You should find your file in your root directory, it will be named
'uploads'.
To solve your problem, you should add a filename to the destination
part, like:
move_uploaded_file($_FILES["upfile"]["tmp_name"],
* * * * * * * * * *$uploadDir.$_FILES["upfile"]["name"] );
best regards
Piotr Nastaly

Ofc, i forgot to add directory separator
move_uploaded_file($_FILES["upfile"]["tmp_name"],
* * * * $uploadDir . DIRECTORY_SEPARATOR . $_FILES["upfile"]["name"] );- Hide quoted text -

- Show quoted text -
Thank-you! It's working fine now.
Apr 8 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: neo002244 | last post by:
The move_uploaded_file() function is very quirky. I want to allow users to upload images to the Web site. Here is the code: if(!move_uploaded_file($_FILES, $imagefile)) { die("Could not move...
1
by: Paul Lamonby | last post by:
Hi, I am using Mac os10.3.3, running Apache and PHP 4.3.6 I am just starting to use my local Sites folder to test php for my sites, but I cannot seem to get move_uploaded_file() or copy() to...
1
by: Felix Natter | last post by:
hi, I would like to upload a file (via a form), then read that (temporary) file and write the contents into a database. The first problem is that open_basedir=/home/CUSTOMER so I can't just read...
1
by: sa | last post by:
Trying to upload a file using win xp/iis/php. I've given full access to all accounts trying to get this to work? Yet I'm still getting read errors. Simplified the script below to the bare...
6
by: Stijn Goris | last post by:
HI all, I have created a script that allows a user to upload a picture. I have an IIS server runing on my own pc but the actual site runs an Apache server. The upload script worked perfectly on...
2
by: Brian | last post by:
Hi I am moving a site to a new server, I have been testing it and one of the pages uses move_uploaded_file, but I get a Permission denied. The directory I am moving it to is chomd of 755, if...
1
by: comp.lang.php | last post by:
Consider my code: if ($this->isSuccessful && is_file($_FILES)) { // STEP 6: MOVE RESUME TO DIRECTORY $uuid = $this->sfug->getUUID(); if (!$uuid) $this->sfug->setUUID(); $uuid =...
5
by: bill | last post by:
I can validate that the file uploaded because is_uploaded_file() returns true. --------- if (is_uploaded_file($_FILES)) { echo "File ". $_FILES ." uploaded successfully.<br />"; }...
4
nallinattu
by: nallinattu | last post by:
I have tried PHP script with localhost and PHP 5 and it works ok. But when script is loaded in server (Linux) except for all validations done well, it simply does not carry out move_uploaded_file ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.