473,498 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File upload problem...

99 New Member
Hi, i got a problem while uploading a file. I got a code from www.w3schools.com. I try the code, but the problem is that, i cannot specify the path where the file should stored. If i want to stored the file as "C:\wamp\www\practices" then what will be the syntax.. please to tell me in the following code.
This is my HTML file
[HTML]
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY>
<form action="file_upload.php" method="post" enctype="multipart/form-data">
<label for="file">File Name:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Upload">
</form>
</BODY>
</HTML>
[/HTML]


and this is my php file
[PHP]
<?php
if(($_FILES["file"]["type"] == "image/gif") || ($_FILES["file"]["type"] == "image/jpeg") || ($_FILES["file"]["type"] == "image/pjpeg") && ($_FILES["file"]["size"] <20000))
{
if($_FILES["file"]["error"] >0)
{
echo "Return Code:" .$_FIELS["file"]["error"]."<br>";
}
else
{
echo "Upload:" .$_FILES["file"]["name"]."<br>";
echo "Type:" .$_FILES["file"]["type"]."<br>";
echo "Size:" .($_FILES["file"]["size"]/1024)."Kb<br>";
echo "Tmep File" .$_FILES["file"]["tmp_name"]. "<br>";

if(file_exists("../robin1/" .$_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"]. "already exists.";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"../robin1/".$FILES["file"]["name"]);
echo "Stored in:". "../robin1/". $_FILES["file"]["name"];

}
}
}
else
{
echo "Invalid file";
}
?>
when i try this code it give the output as
Upload:save-petrol.gif
Type:image/gif
Size:123.631835938Kb
Tmep FileC:\wamp\tmp\phpBD.tmp
Stored in:../robin1/save-petrol.gif
but, i dont know where is this file stored. Please help me............
[/PHP]
Oct 19 '07 #1
4 7397
JeremyMiller
69 New Member
Change this line to indicate your directory:

[php]
move_uploaded_file($_FILES["file"]["tmp_name"],"../robin1/".$FILES["file"]["name"]);
[/php]

Something like

[php]
move_uploaded_file($_FILES["file"]["tmp_name"],"C:/wamp/www/practices/".$FILES["file"]["name"]);
[/php]

should work depending on your server setup and where the script is running from.
Oct 19 '07 #2
robin1983
99 New Member
When I try that, i got the following error message..
Upload:save-petrol.gif
Type:image/gif
Size:123.631835938Kb
Tmep FileC:\wamp\tmp\php5E.tmp

Warning: move_uploaded_file(C:/wamp/www/practices/) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\practices\file_upload.php on line 22

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php5E.tmp' to 'C:/wamp/www/practices/' in C:\wamp\www\practices\file_upload.php on line 22
Change this line to indicate your directory:

[php]
move_uploaded_file($_FILES["file"]["tmp_name"],"../robin1/".$FILES["file"]["name"]);
[/php]

Something like

[php]
move_uploaded_file($_FILES["file"]["tmp_name"],"C:/wamp/www/practices/".$FILES["file"]["name"]);
[/php]

should work depending on your server setup and where the script is running from.
Oct 19 '07 #3
robin1983
99 New Member
Thanks, i did myself
When I try that, i got the following error message..
Upload:save-petrol.gif
Type:image/gif
Size:123.631835938Kb
Tmep FileC:\wamp\tmp\php5E.tmp

Warning: move_uploaded_file(C:/wamp/www/practices/) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\practices\file_upload.php on line 22

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\wamp\tmp\php5E.tmp' to 'C:/wamp/www/practices/' in C:\wamp\www\practices\file_upload.php on line 22
Oct 19 '07 #4
HongThao
4 New Member
Dear robin1983,
Your upload code is perfectly except one line is:
[PHP] move_uploaded_file($_FILES["file"]["tmp_name"],
"../robin1/".$FILES["file"]["name"]);[/PHP]
Where is your "practices" folder? Is it the same level with your coding file or not? If "practices" folder stay at same level at your php file you only have to change your code like this:
[PHP] move_uploaded_file($_FILES["file"]["tmp_name"],"practices/".$_FILES["file"]["name"]);[/PHP]
or you can tell me exactly where is "practices" folder, comparing with your php file. I'll tell you its path.

Good luck
Oct 19 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
3909
by: matt | last post by:
I have compiled some code, some written by me, some compiled from various sources online, and basically i've got a very simple flat file photo gallery. An upload form, to upload the photos and give...
3
2833
by: Bijoy Naick | last post by:
I've written a simple file upload user control in VB .NET. It comprises of an InputFile HTML Server Control, an Upload button and a message label. User clicks on the Browse button of the...
6
4119
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
18
4313
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
4
4448
by: Matt Jensen | last post by:
Howdy I've got a rather strange issue occuring. I used forms based .NET authentication, although I'm also setting some session variables when people login. However, I've found when people use...
5
1578
by: William LaMartin | last post by:
I have a VB ASP.Net application where the user can upload a file using the FileUpload server control. I also want a thumbnail to be created for this file. Unfortunately I can see no means to...
4
2379
by: riteshjain82 | last post by:
Hi, Please go through this: I am having a file (default.asp) on which i am taking many details from a user before mailing it to someone. I have also provided the user with a facility of...
6
3028
by: Vic Spainhower | last post by:
Hello, I am trying to do a FTP file upload which works fine on my localhost but on my ISP server it fails. I can't seem to find where I can go to find the specific cause of the failure. In both...
7
3165
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
1
2709
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
0
7125
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
7002
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
7165
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
7203
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
6885
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
7379
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
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
290
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.