473,508 Members | 2,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload script error

So I wrote this upload script and I keep getting errors and can't get
it to work. I'm running ubuntu linux and here is my code:

<html>
<head>
<title>Upload</title>
</head>
<body>
<?php
if(isset ($_POST['submit'])) {
if (move_uploaded_file ($_FILES['file']['tmp_name'],
"../upload/{$_FILES['file']['name']}")) {
echo 'Your file has been uploaded';}
else {
echo 'Your file could not be uploaded because: ';
switch ($_FILES['file']['error']) {
case 1:
echo 'The file exceeds the upload_max_filesize setting in php.ini';
break;
case 2:
echo 'The files excees the MAX_FILE_SIZE setting in the HTML form';
break;
case 3:
echo 'The file was only partially uploaded';
break;
case 4:
echo 'No file was uploaded';
break;
}}}
?>
<form action="upload.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE="50000">
<input type="file" name="file">
<input type="submit" name="submit" value="Upload">
</form>
</body>
</html>

I keep getting 2 errors:

Warning: move_uploaded_file(../upload/whatever.txt): failed to open
stream: No such file or directory in /var/www/upload.php on line 10

Warning: move_uploaded_file(): Unable to move '/tmp/phpUztFu8' to
'../upload/whatever.txt' in /var/www/upload.php on line 10

What does this mean and how do I fix it?

Nov 30 '05 #1
4 1424
br************@gmail.com wrote:
So I wrote this upload script and I keep getting errors and can't get
it to work. I'm running ubuntu linux and here is my code:

<html>
<head>
<title>Upload</title>
</head>
<body>
<?php
if(isset ($_POST['submit'])) {
if (move_uploaded_file ($_FILES['file']['tmp_name'],
"../upload/{$_FILES['file']['name']}")) {


You should put a real path to a directory here instead of a relative one.

And make sure the user that runs as PHP (often apache, nobody, or www-data)
has write-right in that directory.

Good luck.

Regards,
Erwin Moller

Nov 30 '05 #2
Ok, well theres the problem then... I'm new to this stuff and I dont
really have any idea how to change directory permissoins. How do I
check the user and the permissoins? I'm running linux btw

Nov 30 '05 #3
ls -l > will print out the directory list with permissions, owner group
and size etc....

chmod 777 folder_name > this will allow the folder to be written to

chown owner:group folder_name > this will change the owner and group of
the folder name

Nov 30 '05 #4
Sean wrote:
ls -l > will print out the directory list with permissions, owner group
and size etc....

chmod 777 folder_name > this will allow the folder to be written to

chown owner:group folder_name > this will change the owner and group of
the folder name


I would not advocate chmod 777 on any directory you want to keep for
yourself.
It opens the directory for read/write for everybody with access to the same
machine.
In a shared hosting environment this is not very safe..

It may be better to have a little chit-chat with your provider and ask him
for a solution with an extra group that contains the original user and
www-data (or whatever apache is running as).
Then change to 774 <dirname>
or even
770

Regards,
Erwin Moller
Dec 1 '05 #5

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

Similar topics

3
11737
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
9
3815
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
9
20877
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at...
21
34327
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
5
3264
by: camphor | last post by:
hi, I have found an upload script in hotscripts and have implemented it into the website, I followed the installation steps to 'give write permissions to php on the upload folder (which is...
0
7410
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...
1
7067
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
7505
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...
0
5650
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,...
1
5060
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3201
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
774
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
440
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.