473,396 Members | 2,011 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,396 software developers and data experts.

Still having probs with file upload

Hi all

Further to my earlier posting and the advice recieved I have now modified my
code but it still doesn't work. I am trying to upload a file from my local PC to
my remote server by using a form.

This is the form

<html>
<head></head>
<body>
<!-- The data encoding type, enctype, MUST be specified as below -->
<form enctype="multipart/form-data" action="upload.php" method="POST">
<!-- MAX_FILE_SIZE must precede the file input field -->
<input type="hidden" name="MAX_FILE_SIZE" value="150000" />
<!-- Name of input element determines name in $_FILES array -->
Send this file: <input name="userfile" type="file" />
<input type="submit" value="Send File" />
</form>
</body>
</html>

and this is the upload.php script to handle the uploaded file

<?php

$uploaddir = 'images/';
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);

echo '<pre>';
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.\n";
} else {
echo "Error uploading file.\n";
}

echo 'Here is some more debugging info:';
print_r($_FILES);

print "</pre>";

?>

I get a success message like this

File is valid, and was successfully uploaded.
Here is some more debugging info:Array
(
[userfile] => Array
(
[name] => 1.jpg
[type] => image/pjpeg
[tmp_name] => C:\WINDOWS\TEMP\php8528.tmp
[error] => 0
[size] => 4435
)

)

But when I look in the directory on my server the file is not there. Now pulling
my hair out as this was supposed to be a simple exercise and I've spent 3 days
on it!! Please help me out here!

Regards
Dynamo
Jul 17 '05 #1
2 1363
Dynamo wrote:
But when I look in the directory on my server the file is not there. Now pulling
my hair out as this was supposed to be a simple exercise and I've spent 3 days
on it!! Please help me out here!


I had this on Windows as well. Seems like you are required to use the
full path when you move_uploaded_file. In your script, you move it to
the images/ dir, this might not work, so move it to getcwd()."images/"
instead and it should work.

Maybe ;)
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #2
In article <34*************@individual.net>, Roy W. Andersen says...

Dynamo wrote:
But when I look in the directory on my server the file is not there. Now pulling
my hair out as this was supposed to be a simple exercise and I've spent 3 days
on it!! Please help me out here!


I had this on Windows as well. Seems like you are required to use the
full path when you move_uploaded_file. In your script, you move it to
the images/ dir, this might not work, so move it to getcwd()."images/"
instead and it should work.

Maybe ;)
Roy W. Andersen


Thanks for that Roy but it seems like my webhosts are having some gremlins. I
tried all day yesterday trying to get my posted code to work without success and
yet now it works even though I haven't made any changes. Really wierd!!

Regards
Dynamo

Jul 17 '05 #3

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

Similar topics

15
by: lawrence | last post by:
I've been using the following function (yes, it is inelegant, what can I say, I wrote it a long time ago) to upload images. Haven't had a problem with it for at least a year, and I don't recall...
13
by: Guy Hocking | last post by:
Hi there, i am creating a database driven login page. I am using code that has been successful in the past, however when i upload it to our web server it displys the following message in the...
5
by: tindog | last post by:
I seem to be caught in a bit of a conundrum with C#. First of all getting books on VS 2003.net then VS 2005 comes out and further a book I have bought to just learn just the language C# (in 21...
2
by: Steve | last post by:
I have remade this page from scratch, it still won't work. I think I have finally got some clues that might be useful. I have 3 <input type="file"> controls on the page. If I use 2, that is if...
16
by: lawrence k | last post by:
I've a file upload script on my site. I just now used it to upload a small text document (10k). Everything worked fine. Then I tried to upload a 5.3 meg Quicktime video. Didn't work. I've...
1
by: Peter Newman | last post by:
ok this is getting far to technical for me now .. lol thank you all for the help yesterday, however im still stumbling on one bit ... heres my code so far Dim InputString() As String Dim...
3
by: Mukesh | last post by:
Thx Sloan for the solution. It is working properly under Full trust When i tried it under Medium trust it was giving error Parser Error Message: Required permissions cannot be acquired....
8
by: sabby | last post by:
I want to use the getline() so that i can enter a entire name in on line. (with spaces) The prob is that i am initializing the variable as "N/A" and saving it to a text file. it is declared as a...
6
Jacotheron
by: Jacotheron | last post by:
I need a PHP script that can upload music files (mp3). The script is for a home project I have started a while ago. I have a MySQL database of all the music that I have. Other computers on the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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.