473,769 Members | 1,882 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem uploading files

pezholio
22 New Member
Hi,

It seems that every time I put together a new script to upload a file I always have problems, here's the latest one:

I've got a form with two file input fields, when I submit the form, everything goes OK, but the files don't upload, the permissions on the folders are fine and dandy (Both 777). Here's my code:

[PHP]if(is_uploaded_ file($_FILES['image']['tmp_name'])){

$target_path = "/home/default/ratemyplace.org .uk/user/htdocs/newsite/images/premimages/";

$target_path = $target_path . basename( $_FILES['image']['name']);

$ext = substr($_FILES['image']['name'], strrpos($_FILES['image']['name'], '.') + 1);
$ext = strtoupper($ext );

if ($ext != "JPG"|"JPEG"|"G IF"|"PNG") {
$errorarray[] = "<li><a href='#image'>S orry, you can only upload images in .jpg, .gif or .png format</a> $ext</li>";
$error ++;
} else {

if(move_uploade d_file($_FILES['image']['tmp_name'], $target_path)) {
$image = basename( $_FILES['image']['name']);
} else{
$errorarray[] = "<li><a href='#image'>T here was an error uploading your image, please try again</a></li>";
$error ++;
}
}

}

if(is_uploaded_ file($_FILES['report']['tmp_name'])){

$target_path = "/home/default/ratemyplace.org .uk/user/htdocs/newsite/uploads/";

$target_path = $target_path . basename( $_FILES['report']['name']);

$ext = substr($_FILES['report']['name'], strrpos($_FILES['report']['name'], '.') + 1);
$ext = strtoupper($ext );

if ($ext != "PDF"|"DOC" ) {
$errorarray[] = "<li><a href='#report'> Sorry, you can only upload reports in .pdf or .doc format</a></li>";
$error ++;
} else {

if(move_uploade d_file($_FILES['report']['tmp_name'], $target_path)) {
$report = basename( $_FILES['report']['name']);
} else{
$errorarray[] = "<li><a href='#report'> There was an error uploading your report, please try again</a></li>";
$error ++;
}
}

}
[/PHP]

Any ideas?

Cheers
Jun 25 '08 #1
1 2128
nashruddin
25 New Member
Have you add enctype to your form? it looks like this:

Expand|Select|Wrap|Line Numbers
  1. <form enctype="multipart/form-data" action="somefile.php" method="post">
  2.  
Jun 25 '08 #2

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

Similar topics

3
2189
by: Mike Walsh | last post by:
I have a problem uploading files with PHP which has me stumped! I am unable to successfully upload files. My simple test script is as follows: <?php if (count($_FILES)) { var_dump($_FILES) ; }
13
4320
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
4
2154
by: Himanshu | last post by:
hi, Can anybody tell me that thru asp.net using c#, how can we upload and download physical files in any table of SQL Server Database. the uploading part is running successfully but the problem arises in the retriving part of the code. i am not getting that how will i able to download the file which is there in the SQL Server database in the field type "image".
0
1252
by: FusionGuy | last post by:
I've created a file uploading handler, implemented as an httpHandler. Each time I attempt to upload a file, or files, my HttpContext.Request.Files property never contains the files that were uploaded. Here's a snippet of my handler code: // *** BEGIN HANDLER CODE *** // public class AutoUpload : IHttpHandler { public void ProcessRequest(HttpContext context) {
15
4145
by: =?ISO-8859-1?Q?J=F8rn?= Dahl-Stamnes | last post by:
Hello folks, I need some help/advice FAST. I have problems with addslashes on my web-servers. After uploading a file, I read the uploaded file, use addslashes on the read data and then insert it into a blob field in a MySQL database. The problem is that this works fine on my internal test web-server (running under RedHat 7.3). But on my production web-server (running Fedora Core 4)
3
3929
by: dreamznatcher | last post by:
Hello, I found a script here: http://www.webtoolkit.info/ajax-file-upload.html which supposedly allows you to upload files using AJAX (I'm not an expert). The site claims it's the best way to upload files out there, and the file size is only 1 kb. I couldn't get it to work for me. I downloaded the files to my computer, and opened the index file with my browser. It doesn't work (the demo on their site does); IE doesn't show any error...
7
2675
by: jambroo | last post by:
Hello, We are currently having issues uploading files using PHP. It seems files below 8MB are uploaded fine, however files above 8.2MB cause the page to timeout or show a 'Cannot find server or DNS Error' error. I have looked around and read about common problems people have uploading and the solutions they have used have not seemed to help. For this particular page i have increased post_max_size,
2
1486
by: Zoliq | last post by:
Hi, I have a serious problem. I'm currently developing an application in which the user should upload many files (600-700 xml files). I've searched the web for a while and so far I realized that there's no way to use the HtmlInputFile class to achive the desired effect just because I can't set programatically the property of the class that stores the path of the selected file. My first approach was to write some javascript code which would...
2
1388
by: =?Utf-8?B?TmV0YWpp?= | last post by:
Hi Experts We are uploading files on the server using HtmlInputfile control with visual studio 2005, 2.0. In this there is an option for user to keep on uploading the files finally file actually uploaded on the server after clicking Upload Button. So when user add the file we store the content of HTMLInputfile control in session object. This overall functionality is working in visual studio 2002, 1.0 environment but the problem we are...
3
5182
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
0
9416
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
10199
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
10032
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
9979
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
8861
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...
1
7393
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5293
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...
1
3948
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 we have to send another system
3
2810
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.