Page 1 of 1

Upload php error: No such file or directory

Posted: 02 Mar 2017, 14:49
by JanMolendijk
Well here i`m again... I wanna use this script
https://coursesweb.net/php-mysql/simple- ... -script_s2

Now i try with an id (int) into this script

Code: Select all

<?php
include('connection.php');

$id = (int) $_GET['id'];

$sql=mysqli_query($conn,"SELECT * FROM `user` WHERE id='" . $id . "' ");
$users=mysqli_fetch_assoc($sql);
?>
Now i try into your code this

Code: Select all

$uploadpath = 'images/$users[email]/';      // directory to store the uploaded files
$max_size = 2000;          // maximum file size, in KiloBytes
$alwidth = 1900;            // maximum allowed width, in pixels
$alheight = 1800;           // maximum allowed height, in pixels
$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png');        // allowed extensions
I getting errors when i use $users[email]

Code: Select all

No such file or directory
I tried also with

Code: Select all

<?php echo $users[email];?>
but still getting the same error

Upload php error: No such file or directory

Posted: 02 Mar 2017, 16:25
by Admin
Hello,
Try this code in the upload script:

Code: Select all

$uploadpath ='images/'. $users['email'] .'/'; // directory to store the uploaded files

//if the folder not exists, create it
if(!file_exists($uploadpath)){
  if(!mkdir($uploadpath, 0755)) echo 'Unable to create the folder: '. $uploadpath;
}
//the rest of your code..

Upload php error: No such file or directory

Posted: 03 Mar 2017, 14:26
by JanMolendijk
I got one question i try to ad for the upload more extensions like avi or mp3
but when i put this i get the error

Code: Select all

The file: 03.avi not has the allowed extension type.

Code: Select all

$allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png', 'avi');  
Is it posible with this script to ad more extensions ?

Edit:
- Sorry it workt just fine thanks for Suporting.