LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-08-2015, 03:11 PM   #1
setni
LQ Newbie
 
Registered: Apr 2015
Posts: 4

Rep: Reputation: Disabled
Upload file procedure


Dear,

I have search solution on web but it's appear nothing to soluce my issue.

I try a simple code to upload file:

Code:
header("Content-Type: text/html;charset=utf-8");
$nom = $_FILES['mon_extrait']['name'];
move_uploaded_file($_FILES['mon_extrait']['tmp_name'], "2oclick/".$nom);
In my computer with local environment, it's worked good
But in my server nothing appear.

Here an extract of my inline php info :
Code:
ile_uploads	On	On
highlight.bg	#FFFFFF	#FFFFFF
highlight.comment	#FF8000	#FF8000
highlight.default	#0000BB	#0000BB
highlight.html	#000000	#000000
highlight.keyword	#007700	#007700
highlight.string	#DD0000	#DD0000
html_errors	Off	Off
ignore_repeated_errors	Off	Off
ignore_repeated_source	Off	Off
ignore_user_abort	Off	Off
implicit_flush	Off	Off
include_path	.:/usr/share/php:/usr/share/pear	.:/usr/share/php:/usr/share/pear
log_errors	On	On
log_errors_max_len	1024	1024
magic_quotes_gpc	Off	Off
magic_quotes_runtime	Off	Off
magic_quotes_sybase	Off	Off
mail.add_x_header	On	On
mail.force_extra_parameters	no value	no value
mail.log	no value	no value
max_execution_time	30	30
max_file_uploads	20	20
max_input_nesting_level	64	64
max_input_time	60	60
max_input_vars	1000	1000
memory_limit	128M	128M
open_basedir	no value

Is an other process that i forgot to do this operation well?

Thanks in advance
 
Old 04-09-2015, 03:13 AM   #2
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
Try something like this:
move_uploaded_file($_FILES['mon_extrait']['tmp_name'], "/absolute/path/to/".$nom) or die ("cannot move uploaded file");

This way you can find out whether the file is moved somewhere or not.


If you don't know the absolute path try

<?php
phpinfo();

?>

Hope this helps
 
Old 04-09-2015, 11:30 AM   #3
setni
LQ Newbie
 
Registered: Apr 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Dear,

I found solution after several research : put chmod -R 777 in my website path and it works fine.
But is it dangerous to process like that?

Thanks
 
Old 04-09-2015, 12:54 PM   #4
j-ray
Senior Member
 
Registered: Jan 2002
Location: germany
Distribution: ubuntu, mint, suse
Posts: 1,591

Rep: Reputation: 145Reputation: 145
It is a security risk. Better if you make a separate directory for the uploads and switch that to 0777 and reset the base directory to the former value.
 
1 members found this post helpful.
Old 04-09-2015, 02:39 PM   #5
setni
LQ Newbie
 
Registered: Apr 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Ok, thanks

I have an other question,
When users create an account, I set a folder (name : ID of this user) with mkdir ('name', 0777); inside an upload folder in my website. But, When user would upload files inside this folder, it creates an error on move_uploaded_file($_FILES['mon_fichier']['tmp_name'],$chemin);
Do you know if I need to do an other thing ?

Thanks

Last edited by setni; 04-09-2015 at 02:40 PM.
 
Old 04-09-2015, 03:03 PM   #6
setni
LQ Newbie
 
Registered: Apr 2015
Posts: 4

Original Poster
Rep: Reputation: Disabled
Solution here : modify the php.ini upload_max_size. For one time, it was simple

Thanks for the support
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
user can upload and download file but not delete file in ftp on thel 6 kukusuku Linux - Server 1 08-21-2011 02:50 AM
Upload file to ftp server -vsftp- but can not delete or change the file once uploaded murattas6 Linux - Server 2 06-26-2009 06:00 AM
web server (fedora core 5) became read-only file system after i upload a file nggs8411 Linux - Server 1 03-26-2007 09:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration