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

File upload errors

4
Hi all,

I am just starting with this programming language.
I was trying to write an upload script to the server but the code is not working. Here is a sample of the code am using to upload the picture:


[PHP]
$put_file = (move_uploaded_file($HTTP_POST_FILES['user_file]['tmp_name'],"../uploads/$HTTP_POST_FILES['user_file']['name'];

if ($put_file){
echo "Your upload was successful";
} else {
echo "Sorry, an error occured so your file could not be uploaded";
}
[/PHP]

Please help. :)
Aug 24 '06 #1
5 2000
vssp
268 100+
Hi friend Try this program

<?php
// In PHP earlier then 4.1.0, $HTTP_POST_FILES should be used instead of
// $_FILES. In PHP earlier then 4.0.3, use copy() and is_uploaded_file()
// instead of move_uploaded_file

$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];

print "<pre>";
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
print "File is valid, and was successfully uploaded. ";
print "Here's some more debugging info:\n";
print_r($_FILES);
} else {
print "Possible file upload attack! Here's some debugging info:\n";
print_r($_FILES);
}
print "</pre>";

?>
Aug 24 '06 #2
Mumo
4
Hi friend,
Thanks for your help, I am trying to change my code as and finding out the server version am using so i can get passed this problem. Thank you so much....
Aug 25 '06 #3
vssp
268 100+
Thanks welcome
Aug 25 '06 #4
Mumo
4
I have changed my code accordingly. But after putting a switch statement for error checking, am getting the error "Cant write to Disk". I dont know what to do to make this work anymore. What could be the possible causes of this error. Am willing to try anything possible to get this working coz it is becoming frustrating for me.

Thanks for your help
Aug 31 '06 #5
vssp
268 100+
I thnik folder permission related issue.
So u give the full permission on uploaded folder
Aug 31 '06 #6

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

Similar topics

15
by: Simon | last post by:
I would like to create a very basic file upload add image form to add to my web site and to keep them in a "tmp" directory within my web hosting file manager once uploaded. I understand the basic...
1
by: Muttly | last post by:
Hey all. I'm trying to upload multiple files. I'm using the chm file from php.net to help me figure it out. I also checked online and say theres a problem with the file. Anyway My html looks like...
6
by: Jonathan | last post by:
I am trying to upload a new version of a file that already exists on my web site. It asks me to overwrite and I choose yes. But when I go to the web page, even a half hour after the upload, the...
4
by: Mitul | last post by:
Hello friends, I need a help for upload media file. I had tried for that but getting following result after uploading wmv file in $_FILE variable. => Array ( => bada_gosht.wmv => =>
4
by: Marko Vuksanovic | last post by:
I am trying to cause the uplaod button, id="Upload",when clicked, to exectue the onClick event for Button1, id="Button1". <asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>...
3
by: siyaverma | last post by:
i am trying to upload csv file from user's computer to main server the code i am using is if(((isset($_GET)) && ($_GET=="yes")) ) { $typefield = $_GET; echo...
2
by: Amzul | last post by:
hello all i search the net for upload picture secure code i fuond this code, and affter i changed it abit it looks like that : <?php class image_upload { var $tmp_image; var...
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...
1
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 Many websites have a form or a link you can use to download a file. You click a form button or click...
2
by: jeddiki | last post by:
Hello, Hopefully I can do this with php I want to allow my clients to upload their pdf or video files to my server without giving them ftp login details. Lets look at PDF's first: This...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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
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,...

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.