473,770 Members | 4,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="multip art/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($_FILE S['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 1380
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_f ile. In your script, you move it to
the images/ dir, this might not work, so move it to getcwd()."image s/"
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.ne t>, 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_f ile. In your script, you move it to
the images/ dir, this might not work, so move it to getcwd()."image s/"
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
12018
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 changing it anytime recently. Nevertheless, the script is suddenly dying on this line: if (copy($uploadedFile, $pathToImageFolder)){ This is the error I get:
13
1866
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 page = ****** Microsoft OLE DB Provider for ODBC Drivers error '80004005' General error Unable to open
5
2357
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 days). I now have ordered, as suggested to me by a few members of the newsgroup to get a Primer type book how ever until then I will use what I have. BUT looking at the C# language my first exercise which happens to be a windows form looks quite...
2
969
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 I click the browse button and choose a file, the page works correctly, by breakpoint in Page_Load() fires, all that good stuff. If I use all 3 of the file upload controls, the pages won't post. There is no error, just nothing happens. So it...
16
4987
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 set the POST limit in php.ini to 8 megs. What reasons, other than the POST limit, would a large upload fail?
1
1063
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 ReturnValue As Integer InputString = Split(InputParm, ";") ' set the query commands
3
1737
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. :::::::::: Source Error:
8
2862
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 string. look at the code: #include <iostream.h> #include <fstream> #include <cstdlib> #include <string> using namespace std; //Account data structure
6
3837
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 network should be able to connect to the database and run queries on the database or upload new music that does not yet exist on the database. The uploaded file's name should be in the following format: ARTIST - TITLE.mp3. I have the code to upload images,...
0
9602
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8905
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.