• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

uploading to new directory fails

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am submitting a form (which creates a directory). That part parts works like a charm. Then, I am trying to upload my files in that directory. Both are going to be on the same page. Yet, the files refuse to go inside my create directory. I don't get it. This is the error message from the console.

Warning: mkdir() [<a href='function.mkdir'>function.mkdir</a>]: No such file or directory in <b>/home/*****/*****/*****/upload.php on line 7 has NOT been created

Warning: file_put_contents(images/$folder/saskype_bla.jpeg) [<a href='function.file-put-contents'>function.file-put-contents</a>]: failed to open stream: No such file or directory in /home/*****/*****/*****/upload.php on line 41
Something went wrong. Check that the file isn't corrupted

And my code for that part.


 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are creating your directory 755? That's drwxr-xr-x. Check the owner of this directory against the apache user or whichever account runs apache HTTP server.

If the owner is not apache then issue a chown too then upload.

And welcome to the Ranch
 
Sami Dma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried also with 777, but to no avail. As for your suggestion, how do you even do that? I've never heard of that before.


 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sami Dma wrote:I tried also with 777, but to no avail. As for your suggestion, how do you even do that? I've never heard of that before.



Do what? chown in PHP? Just like you mkdir.

Further inspection, your $folder goes in the images folder. And from the error what does this evaluate to? images/$folder/saskype_bla.jpeg? Is this the correct path?
 
Sami Dma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it doesn't do that. I ensured myself that it wouldn't do that. It just doesn't save the file at all. With the code I have now, I can create a folder (in the same directory as my images folder), and I can save my image in the images folder.

Yes, as well as

Check the owner of this directory against the apache user or whichever account runs apache HTTP server.

 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To check what user Apache is running as, either in shell script (assuming unix/linux):
"ps aux | grep apache" or "ps aux | grep httpd" depending on the process name

Or you can use the php to find


If the newly created folders are owned by this user then you will be fine.
 
Sami Dma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK... it returns to me a username from my database. It doesn't return anything resembling a linux line (or windows for that matter) ??? What the...
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sami Dma wrote:OK... it returns to me a username from my database. It doesn't return anything resembling a linux line (or windows for that matter) ??? What the...



This is indeed odd. Apache HTTP server process is supposed to be system initiated process rather than a user process.

I actually somewhat tested your script substituting the $_POST[] stuff as strings:


For me, it works once I grant permission to public or everyone for the top folder (ie 757)

Note that the user Apache HTTP runs as is "_www" and my login user is "yktsang01"
Screen-shot-2013-07-18-at-00.35.12-AM.png
[Thumbnail for Screen-shot-2013-07-18-at-00.35.12-AM.png]
output
 
Sami Dma
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing some testing right now. I will let you know in the future how they go. I haven't come up with a solution to this dilemma yet. I am trying more things. I will keep you posted though
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
ScroogeXHTML 8.7 - RTF to HTML5 and XHTML converter
https://coderanch.com/t/730700/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic