473,394 Members | 1,867 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,394 software developers and data experts.

move_uploaded_file returns false

Hello,
Please help in the following problem:
I have written a PHP5 script uploading file:

if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
isset($_POST['EditionFile']) && isset($_POST['Year']) &&
isset($_POST['Month']))
{
if (is_uploaded_file($_FILES['SelectEditionFile']['tmp_name']))
{
// Load file:
$file = $_FILES['SelectEditionFile']['name'];
$ext = @substr($file,
@strrpos($file, '.') ? @strrpos($file, '.') + 1 : @strlen($file),
@strlen($file));
$paper = 'Paper/Blask_' . $_POST['Year'] . '-' . $_POST['Month'] . '.' .
$ext;
@unlink($paper);
if (!move_uploaded_file($_FILES['SelectEditionFile']['tmp_name'], $paper))
{
$_SESSION['Error'] = 'Cannot move file.';
}
....

The problem is that 'Cannot move file' is reached during execution of the
script. I don't know why. I have checked priviledges on $paper folder: it
looks OK.
Will you help me?
/RAM/
Mar 13 '08 #1
2 5847
On Thu, 13 Mar 2008 20:48:32 +0100, R.A.M. <r_********@poczta.onet.pl
wrote:
Hello,
Please help in the following problem:
I have written a PHP5 script uploading file:

if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
isset($_POST['EditionFile']) && isset($_POST['Year']) &&
isset($_POST['Month']))
{
if (is_uploaded_file($_FILES['SelectEditionFile']['tmp_name']))
{
// Load file:
$file = $_FILES['SelectEditionFile']['name'];
$ext = @substr($file,
@strrpos($file, '.') ? @strrpos($file,
'.') + 1 : @strlen($file),
@strlen($file));
$paper = 'Paper/Blask_' . $_POST['Year'] . '-' .
$_POST['Month'] . '.' .
$ext;
@unlink($paper);
if
(!move_uploaded_file($_FILES['SelectEditionFile']['tmp_name'], $paper))
{
$_SESSION['Error'] = 'Cannot move file.';
}
...

The problem is that 'Cannot move file' is reached during execution of the
script. I don't know why. I have checked priviledges on $paper folder:it
looks OK.

What are the priviledges, and what does realpath($paper); tell you about
the directory?
--
Rik Wasmus
Mar 13 '08 #2
Rik Wasmus wrote:
What are the priviledges, and what does realpath($paper); tell you about
the directory?
The priviledges are rwxrwxr-x.
echo realpath($paper) prints nothing, so $papaer is null or empty, I think.
The problem was not occuring so far.
/RAM/
Mar 17 '08 #3

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: 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...
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...
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 />"; }...
3
by: kujtim | last post by:
my html file is <html> <head> <title>File Upload Form</title> </head> <body> This form allows you to upload a file to the server.<br>
7
by: nicemotion | last post by:
Hi all, the following easy script correctly insert a record in the DB but is not moving the images (Logo and Foto) to the server /foto folder. can't understand why 'cause the script is easy...
3
by: groupie | last post by:
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...
1
by: Sebzzz | last post by:
Hi, I have a form where user can attach a resumé and I want my script to put it in the cv folder of the server and then send me the link by e- mail. However, I tried a lot of combinations...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.