Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,209,403 members, 8,005,942 topics. Date: Monday, 18 November 2024 at 01:30 PM |
Nairaland Forum / Science/Technology / Webmasters / Code To Upload Files To Server, Help (2058 Views)
How To Upload A Song(your Song) Or Other Application Or File To Waptrick / Web Content Scattered After Upload To Live Server! Help / How To Upload Mysql Database To Server (2) (3) (4)
Code To Upload Files To Server, Help by Joit(m): 11:44am On Jun 13, 2009 |
Nairalander webmaster I used the php code below which worked well on php 5.0.4 but not on php 5.2.8 <?php // start it now because it must go before headers session_start(); //This is the directory where the zipped folder will be saved $target = 'uploads/'; $target = $target . basename( $_FILES['uploadedfile']['name']); //create a short variable names for upload $uploadedfile=($_FILES['uploadedfile']['name']); $uploadedfile_type=($_FILES['uploadedfile']['type']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target)) { //successful upload message echo "<p>The file ". basename( $_FILES['uploadedfile']['name']). " has been successfully uploaded</span>"; } else { echo "<p>Sorry, the file could not be uploaded.</span>"; } ?> Pls help me on the upload code to work on all versions |
Re: Code To Upload Files To Server, Help by Nobody: 12:37pm On Jun 13, 2009 |
Sorry, i seem to have forgotten how to write upload codes in all versions! Nonsense, your post is lacking too much information, what is the server you are using? localhost/cpanel/bluehost or what? And what was the error report you saw? this is not a downloading place but rather discussing. . . |
Re: Code To Upload Files To Server, Help by segsalerty(m): 1:30pm On Jun 13, 2009 |
Uhmmm codes fit bbreak somebody's head for here ooooo! |
Re: Code To Upload Files To Server, Help by kolitos007: 6:03pm On Jun 13, 2009 |
Good point dhtml, can't debug your issue without knowing what error messages you are getting, you may be using a different path on your upgraded server, can you pass more info and also check your form tag that you have got (enctype="multipart/form-data") in it. |
Re: Code To Upload Files To Server, Help by Nobody: 7:29pm On Jun 13, 2009 |
Exactly, i can list like up to 20 different kinds of errors you could get, but what i really suspect is that you are not getting a server configuration right (the new server). . .maybe max_upload_size or even post_upload_size provided you have not tampered with the code. . . 'cos all the sites i have done since the time of php 4 till now are still uploading fine, i am not aware of a new uploading code. . . it is either you make use of http upload or ftp. . . . Give us more details, or at least give up a link to that page on your site. . .that is the best i can do |
Re: Code To Upload Files To Server, Help by kolitos007: 7:38pm On Jun 13, 2009 |
Exactly, i can list like up to 20 different kinds of errors you could get, Excellent point, i think it is the php.ini setting, could be trying to upload files that are above the maximum setting, some people dont' know that when they need help they need to be more specifi to solve problems. |
Re: Code To Upload Files To Server, Help by quadrillio(m): 2:43pm On Jun 14, 2009 |
people need to learn how to explain their problem, I always tell my students that one of the major rule of asking computer related questions is "WRITE DOWN THE ERROR MESSAGE" maybe we need to add that tutorial to our post, LOL |
Re: Code To Upload Files To Server, Help by Nobody: 5:17pm On Jun 14, 2009 |
That one is even more tiresome in the computer section when someone just comes and says my pc is not booting or my printer is not working. . . No operating system, version, model of pc, model of printer. . . .no error message report. . . .i am tired of shouting! Once the question is not clear, i usually skip it and wait for the next good samaritan come |
Re: Code To Upload Files To Server, Help by NAIJAVOICE(m): 8:44pm On Jun 14, 2009 |
why don't you use of smf to upload direct from control panel. |
Re: Code To Upload Files To Server, Help by Nobody: 5:31am On Jun 15, 2009 |
NAIJAVOICE:smf keh? there are times when you need to create an upload script, possibly for your client to upload something. . . Just like sometimes, you may need a site to dynamically generate flash content, for instance, i can write a php script to say read a thread on NL, and render that thread as flash content using the php ming functions. . . Just like, i can write a php script to convert the same thread to an image - like a screen capture. . . . Depending on the task at hand, and of course, those same tasks i mentioned, of course, you can do them manually too. . .depends |
Re: Code To Upload Files To Server, Help by segsalerty(m): 8:13pm On Jun 15, 2009 |
over dependency on SMF ! where my friend Mr Dual Core? he is the number 1 |
Re: Code To Upload Files To Server, Help by Nobody: 8:28pm On Jun 15, 2009 |
@segsalert, dont let DC ban u o, u know he is still more highly rated as a mod compared to me. . . |
Re: Code To Upload Files To Server, Help by Joit(m): 11:01am On Jun 16, 2009 |
I'm very sorry for not giving the details. Here are the details: Assuming I upload a file named 'license.rtf', it brings this error message: Warning: move_uploaded_file(/home/fceobudu/public_html/uploads/license.rtf) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/fceobudu/public_html/admin_upload_fns.php on line 57 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpdAFrb1' to '/home/fceobudu/public_html/uploads/license.rtf' in /home/fceobudu/public_html/admin_upload_fns.php on line 57 System details Operating system: Linux Apache version: 1.3.41 (Unix) PHP version 5.2.8 Pls I'm waiting your replies. |
Re: Code To Upload Files To Server, Help by kolitos007: 2:02pm On Jun 16, 2009 |
Joit: Hello mate, Your problem is the fact that you are trying to upload rtf file as, however so far, this program does not recognise rtf, and docx as a document type, so I suggest converting it to something else hope that helps |
Re: Code To Upload Files To Server, Help by Nobody: 4:50pm On Jun 16, 2009 |
I will take a look at it later |
Re: Code To Upload Files To Server, Help by nitation(m): 5:09pm On Jun 16, 2009 |
On the contrary kolitos007 the user didn't specify what file extension must be accepted according to his code. One of the problems is that he should change the permission for his directory uploads to 0777 and lets see what happens. - nitation |
Re: Code To Upload Files To Server, Help by Nobody: 6:45pm On Jun 16, 2009 |
Looking at the code again, the code is very much alright. . . . step 1: follow nitation's advice, hopefully that should work, or else step 2: change the line if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target)) to if(copy($_FILES['uploadedfile']['tmp_name'], $target)) that is because some servers will not give you right to move a temp file, and will auto delete it followin end of session |
Re: Code To Upload Files To Server, Help by Joit(m): 7:59am On Jul 22, 2009 |
Hello xhtml *dhtml: The error changed to this when I tried to upload a file name 'Brief296.pdf': Warning: copy(uploads//Brief296.PDF) [function.copy]: failed to open stream: Permission denied in /home/fceobudu/public_html/admin_upload_fns.php on line 60 Please help |
Re: Code To Upload Files To Server, Help by yawatide(f): 11:10am On Jul 22, 2009 |
Joit, Did you do as nitation said? Change permissions on the file to 777? Do that at the very least then let us know what's up. There should be a chmod() fxn in php I believe. Good luck! |
Re: Code To Upload Files To Server, Help by Joit(m): 8:31am On Jul 24, 2009 |
yawa-ti-de The error continues: Warning: copy(uploads//Brief296.PDF) [function.copy]: failed to open stream: Permission denied in /home/fceobudu/public_html/admin_upload_fns.php on line 62 but 0755 is the permission on 'upload' folder in the public_html |
Re: Code To Upload Files To Server, Help by Afam(m): 9:16am On Jul 24, 2009 |
Joit: The problem can only be diagnosed if we know what is happening on line 62 on the file admin_upload_fns.php. Without the specific content on that line being made available it will be like someone going into a battle with a blindfold. Possible causes will range from write access to the folder specified to non existence of the folder itself, incorrect folder path to disallowed file extension etc. PHP error reporting style makes life easy for anyone. |
Re: Code To Upload Files To Server, Help by biggjoe(m): 3:01pm On Jul 24, 2009 |
he just said it, the permission is 0775 why not chmod it to 777, i believe thats where the whole issue lies. or cant you chmod? @ afam, line 62 is presumably where he has: if(copy($_FILES['uploadedfile']['tmp_name'], $target)) |
Re: Code To Upload Files To Server, Help by Afam(m): 5:05pm On Jul 24, 2009 |
biggjoe: @biggjoe, Thanks for pointing that out. It would everyone if you could post exactly what line 62 is telling him considering the fact that the error has come on different lines depending on what he is doing at different times. Hope he sorts out the permission problem first anyway to help narrow down the options. |
(1) (Reply)
I.p Changer, Site Developers And Forum Info / Register With GLOBAL DOMAINS INTERNATIONAL And Make Money From It / Jumia Vs Jiji..model, How Do They Differ
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 39 |