Jump to content

File Upload Problem


azraelGG

Recommended Posts

i looked some tutorial how to upload files, and got some script i should use for that, but i cant set good values for my destination folder i guess

can you tell me where do i get things wrong

 

if(!empty($_FILES)){
   $tempFile = str_replace(" ", "", $_FILES['picUpload']['tmp_name']);
   $targetPath = $_SERVER['DOCUMENT_ROOT'].'/images/mehanizacija/';
   $broj = rand(100,999);
   $targetFile = str_replace(" ", "", $targetPath.$broj.'-'.$_FILES['picUpload']['name']);
   $linkPicture = str_replace(" ", "", "http://localhost/images/mehanizacija/".$broj.'-'.$_FILES['picUpload']['name']);
   move_uploaded_file($tempFile, $targetFile);
  }

 

Warning: move_uploaded_file(/home/azrael/htdocs/images/mehanizacija/408-pics01.jpg): failed to open stream: No such file or directory in /home/azrael/htdocs/agro/stroj.php on line 76

 

Warning: move_uploaded_file(): Unable to move '/tmp/phpKEpgr3' to '/home/azrael/htdocs/images/mehanizacija/408-pics01.jpg' in /home/azrael/htdocs/agro/stroj.php on line 76

 

line76

move_uploaded_file($tempFile, $targetFile);

 

i use submit button from form that have multiple forms so i need that if(!empty($_FILES))

and in $linkPicture can i also use $_SERVER['DOCUMENT_ROOT'] so if i send this to some server he will look in my root folder and not directly on link that i will need to change

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.